Skip to content

Commit bfbd1b9

Browse files
daleesTravis Holton
andauthored
Keystone Auth: Remove authorization-* args from apiserver bootstrap (#600)
In kubernetes 1.29 kubeadm is not able to authorize the admin user because it is trying to find a webhook that doesn't yet exist. Solution: don't add webhook at init time but instead wait till after kubeadm has completed and then use kustomize to patch the kube-apiserver with the authorization-mode argument to add "Webhook". It is possible to add this option to the kube-apiserver arguments separately so it can just be appended to the list of args along with the authorization/authentication config paths. Related issue: kubernetes/cloud-provider-openstack#2575 Co-authored-by: Travis Holton <travisholton@catalystcloud.nz>
1 parent e35bbc8 commit bfbd1b9

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

charts/openstack-cluster/templates/_helpers.tpl

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,16 @@ ignition:
392392
Create folders necessary for webhook integration.
393393
*/}}
394394
{{- define "openstack-cluster.webhookPatches" }}
395+
{{- $authWebhook := .Values.authWebhook }}
395396
preKubeadmCommands:
396397
- mkdir -p /etc/kubernetes/webhooks
397398
- mkdir -p /etc/kubernetes/patches
399+
{{- if eq $authWebhook "k8s-keystone-auth" }}
400+
- mkdir -p /etc/kubernetes/keystone-auth
401+
postKubeadmCommands:
402+
- cp /etc/kubernetes/manifests/kube-apiserver.yaml /etc/kubernetes/keystone-auth/kube-apiserver.yaml
403+
- kubectl kustomize /etc/kubernetes/keystone-auth -o /etc/kubernetes/manifests/kube-apiserver.yaml
404+
{{- end }}
398405
{{- end }}
399406

400407
{{/*
@@ -409,11 +416,7 @@ webhooks and policies for audit logging can be added here.
409416
extraArgs:
410417
v: {{ $ctx.Values.apiServer.logLevel | quote }}
411418
{{- if ne $authWebhook "none" }}
412-
{{- if eq $authWebhook "k8s-keystone-auth" }}
413-
authorization-mode: Node,Webhook,RBAC
414-
authentication-token-webhook-config-file: /etc/kubernetes/webhooks/keystone_webhook_config.yaml
415-
authorization-webhook-config-file: /etc/kubernetes/webhooks/keystone_webhook_config.yaml
416-
{{- else if eq $authWebhook "azimuth-authorization-webhook" }}
419+
{{- if eq $authWebhook "azimuth-authorization-webhook" }}
417420
authorization-config: /etc/kubernetes/webhooks/authorization_config.yaml
418421
{{/*
419422
Add else if blocks with other webhooks and apiServer arguments (i.e. audit logging)
@@ -466,6 +469,25 @@ Produces integration for k8s-keystone-auth webhook on apiserver
466469
{{- define "openstack-cluster.k8sKeystoneAuthWebhook" }}
467470
files:
468471
{{- include "openstack-cluster.webhookMountDirectoryFile" . }}
472+
- path: /etc/kubernetes/keystone-auth/kustomization.yml
473+
permissions: "0644"
474+
owner: root:root
475+
content: |
476+
resources:
477+
- kube-apiserver.yaml
478+
patches:
479+
- patch: |-
480+
- op: add
481+
path: /spec/containers/0/command/-
482+
value: --authentication-token-webhook-config-file=/etc/kubernetes/webhooks/keystone_webhook_config.yaml
483+
- op: add
484+
path: /spec/containers/0/command/-
485+
value: --authorization-webhook-config-file=/etc/kubernetes/webhooks/keystone_webhook_config.yaml
486+
- op: add
487+
path: /spec/containers/0/command/-
488+
value: --authorization-mode=Webhook
489+
target:
490+
kind: Pod
469491
- path: /etc/kubernetes/webhooks/keystone_webhook_config.yaml
470492
content: |
471493
---

0 commit comments

Comments
 (0)