Skip to content

Commit

Permalink
fix: bug in kube client apply for mutating manifest when webhook is o…
Browse files Browse the repository at this point in the history
…utside cluster. (#16)

* bug: fix kube client apply for mutating manifest.

* chore: Fix CI lint

---------

Co-authored-by: David MICHENEAU <david.micheneau@orange.com>
  • Loading branch information
dmicheneau and David MICHENEAU authored Sep 27, 2024
1 parent cccd0ab commit 1605b47
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
`webhook` - Fix kube client apply for mutating manifest.
```
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
go-version-file: 'go.mod'
- run: go mod download
- run: go build -v .
- run: make
- name: Run linters
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
examples/
bin/
dist/
config/manifests/mutatingWebhookConfiguration.yaml
config/manifests/mutatingWebhookConfiguration.yaml
1 change: 1 addition & 0 deletions cmd/webhook/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func generateCert(orgs, dnsNames []string, commonName string) (*bytes.Buffer, *b
// print CA certificate if insideCluster is false
if !insideCluster {
writeNewCA(caPEM, manifestWebhookPath)
time.Sleep(2 * time.Second)
applyManifest(manifestWebhookPath)

debugLogger.Printf("CA certificate Encoded: %s", base64.StdEncoding.EncodeToString(caPEM.Bytes()))
Expand Down
2 changes: 1 addition & 1 deletion config/manifests/mutatingWebhookConfiguration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ webhooks:
# path: /mutate
# port: 8443
# CA certificate with BEGIN and END lines - base64 encoded
caBundle: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSU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