This repository was archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Add Admission webhook to lokomotive #704
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8fbdac4
Add mutating admission webhook
knrt10 ecf29bd
assets/: format using terraform fmt
knrt10 7d1f0a1
Add go code for admission webhook
knrt10 474abab
Ensure upgrade for lokomotive component
41b63b0
Update bootkube image
1ae44f6
Fix install values while upgrading releases
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| webhook: | ||
| servingKey: ${serving_key} | ||
| servingCert: ${serving_cert} |
23 changes: 23 additions & 0 deletions
23
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/.helmignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Patterns to ignore when building packages. | ||
| # This supports shell glob matching, relative path matching, and | ||
| # negation (prefixed with !). Only one pattern per line. | ||
| .DS_Store | ||
| # Common VCS dirs | ||
| .git/ | ||
| .gitignore | ||
| .bzr/ | ||
| .bzrignore | ||
| .hg/ | ||
| .hgignore | ||
| .svn/ | ||
| # Common backup files | ||
| *.swp | ||
| *.bak | ||
| *.tmp | ||
| *.orig | ||
| *~ | ||
| # Various IDEs | ||
| .project | ||
| .idea/ | ||
| *.tmproj | ||
| .vscode/ |
6 changes: 6 additions & 0 deletions
6
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/Chart.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v2 | ||
| name: lokomotive | ||
| description: A Helm chart providing Lokomotive-specific system workloads like admission webhook server. | ||
| type: application | ||
|
|
||
| version: 0.1.0 |
5 changes: 5 additions & 0 deletions
5
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/templates/00-common.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
knrt10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| metadata: | ||
| name: admission-webhook-server | ||
| automountServiceAccountToken: false | ||
8 changes: 8 additions & 0 deletions
8
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/templates/01-secrets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: admission-webhook-server | ||
| type: Opaque | ||
| data: | ||
| key.pem: "{{ .Values.webhook.servingKey }}" | ||
| cert.pem: "{{ .Values.webhook.servingCert }}" |
13 changes: 13 additions & 0 deletions
13
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/templates/02-service.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: admission-webhook-server | ||
| labels: | ||
| k8s-app: admission-webhook-server | ||
| spec: | ||
| ports: | ||
| - port: 443 | ||
| targetPort: 8080 | ||
| name: admission-webhook-server | ||
| selector: | ||
| k8s-app: admission-webhook-server |
48 changes: 48 additions & 0 deletions
48
...s/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/templates/03-deployment.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: admission-webhook-server | ||
| labels: | ||
| k8s-app: admission-webhook-server | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| k8s-app: admission-webhook-server | ||
| template: | ||
| metadata: | ||
| labels: | ||
| k8s-app: admission-webhook-server | ||
| spec: | ||
| tolerations: | ||
| - key: node-role.kubernetes.io/master | ||
| effect: NoSchedule | ||
| containers: | ||
| - name: admission-webhook-server | ||
| securityContext: | ||
| readOnlyRootFilesystem: true | ||
| runAsNonRoot: true | ||
| runAsUser: 65534 | ||
| runAsGroup: 65534 | ||
| image: "quay.io/kinvolk/lokomotive-admission-webhook-server:v0.1.0" | ||
| imagePullPolicy: IfNotPresent | ||
| args: | ||
| - -logtostderr=true | ||
| - -stderrthreshold=WARNING | ||
| - -v=2 | ||
| volumeMounts: | ||
| - name: admission-webhook-server | ||
| mountPath: /etc/certs | ||
| readOnly: true | ||
| resources: | ||
| limits: | ||
| cpu: 300m | ||
| memory: 50Mi | ||
| requests: | ||
| cpu: 300m | ||
| memory: 50Mi | ||
| serviceAccountName: admission-webhook-server | ||
| volumes: | ||
| - name: admission-webhook-server | ||
| secret: | ||
| secretName: admission-webhook-server |
22 changes: 22 additions & 0 deletions
22
...motive-kubernetes/bootkube/resources/charts/lokomotive/templates/04-mutating-webhook.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: MutatingWebhookConfiguration | ||
| metadata: | ||
| name: admission-webhook-server | ||
| labels: | ||
| k8s-app: admission-webhook-server | ||
| webhooks: | ||
| - name: mutating.kinvolk.io | ||
| clientConfig: | ||
| caBundle: "{{ .Values.webhook.servingCert }}" | ||
| service: | ||
| name: admission-webhook-server | ||
| namespace: lokomotive-system | ||
| path: /mutate | ||
| rules: | ||
| - operations: ["CREATE"] | ||
| apiGroups: [""] | ||
| apiVersions: ["v1"] | ||
| resources: ["serviceaccounts"] | ||
| sideEffects: None | ||
| failurePolicy: Ignore | ||
| admissionReviewVersions: ["v1"] |
3 changes: 3 additions & 0 deletions
3
assets/lokomotive-kubernetes/bootkube/resources/charts/lokomotive/values.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| webhook: | ||
| servingKey: | ||
| servingCert: |
46 changes: 46 additions & 0 deletions
46
assets/lokomotive-kubernetes/bootkube/tls-admission-webhook.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| resource "tls_private_key" "admission-webhook-server" { | ||
| algorithm = "RSA" | ||
| rsa_bits = "2048" | ||
| } | ||
|
|
||
| resource "tls_cert_request" "admission-webhook-server" { | ||
| key_algorithm = tls_private_key.admission-webhook-server.algorithm | ||
| private_key_pem = tls_private_key.admission-webhook-server.private_key_pem | ||
|
|
||
| subject { | ||
| common_name = "admission-webhook-server" | ||
| organization = "kinvolk" | ||
| } | ||
|
|
||
| dns_names = [ | ||
| "admission-webhook-server", | ||
| "admission-webhook-server.lokomotive-system", | ||
| "admission-webhook-server.lokomotive-system.svc", | ||
| "admission-webhook-server.lokomotive-system.svc.cluster", | ||
| "admission-webhook-server.lokomotive-system.svc.cluster.local", | ||
| ] | ||
| } | ||
|
|
||
| resource "tls_locally_signed_cert" "admission-webhook-server" { | ||
| cert_request_pem = tls_cert_request.admission-webhook-server.cert_request_pem | ||
|
|
||
| ca_key_algorithm = tls_self_signed_cert.kube-ca.key_algorithm | ||
| ca_private_key_pem = tls_private_key.kube-ca.private_key_pem | ||
| ca_cert_pem = tls_self_signed_cert.kube-ca.cert_pem | ||
|
|
||
| validity_period_hours = var.certs_validity_period_hours | ||
|
|
||
| allowed_uses = [ | ||
| "key_encipherment", | ||
| "digital_signature", | ||
| "server_auth", | ||
| ] | ||
| } | ||
|
|
||
| resource "local_file" "lokomotive" { | ||
| filename = "${var.asset_dir}/charts/lokomotive-system/lokomotive.yaml" | ||
| content = templatefile("${path.module}/resources/charts/lokomotive.yaml", { | ||
| serving_key = base64encode(tls_private_key.admission-webhook-server.private_key_pem) | ||
| serving_cert = base64encode(tls_locally_signed_cert.admission-webhook-server.cert_pem) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.