Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support keystone-auth #297

Merged
merged 28 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
09ba3ff
feat: support keystone-auth
okozachenko1203 Jan 22, 2024
332c9a7
render template
okozachenko1203 Jan 22, 2024
51cb82f
fix unittest
okozachenko1203 Jan 22, 2024
fd59bf7
fix flake and isort issue
okozachenko1203 Jan 22, 2024
76af9a0
fix manifest path
okozachenko1203 Jan 22, 2024
ac73648
fix jinja env initi
okozachenko1203 Jan 22, 2024
5b2b4b6
fix calico path
okozachenko1203 Jan 22, 2024
d00a0ad
fix flake8 error
okozachenko1203 Jan 22, 2024
63be902
Configuration on K8S master for authentication and/or authorization
okozachenko1203 Jan 23, 2024
cb056ef
fix lint errors
okozachenko1203 Jan 23, 2024
b669827
workaround for jsonpath for slices
okozachenko1203 Jan 23, 2024
8f3583e
add missing webhook file content
okozachenko1203 Jan 23, 2024
b942afb
mount cloud ca in keystone-webhook for tls support and add /v3 in ide…
okozachenko1203 Jan 23, 2024
12a3b9e
fix indentation
okozachenko1203 Jan 23, 2024
832347a
support http endpoints
okozachenko1203 Jan 23, 2024
ee353ba
write k8s-keystone-auth helm chart and use helm template
okozachenko1203 Feb 19, 2024
b5f0d89
revert manifest changes
okozachenko1203 Feb 19, 2024
0b39971
fix template output
okozachenko1203 Feb 19, 2024
14c609d
set namespace for helm template rendered manifests
okozachenko1203 Feb 19, 2024
7a6593a
set ca cert optionally
okozachenko1203 Feb 19, 2024
04f9bf6
set hostnetwork in keystone-auth chart
okozachenko1203 Feb 19, 2024
f56f1a3
fix helm template rendering
okozachenko1203 Feb 19, 2024
b2bf525
fix volume mount
okozachenko1203 Feb 19, 2024
45c9535
fix lint errors
okozachenko1203 Feb 19, 2024
dc3e64b
remove static manifests
okozachenko1203 Feb 20, 2024
d833cd6
add webhook file
okozachenko1203 Feb 20, 2024
4d9e7fb
resolve comments
okozachenko1203 Feb 26, 2024
c42af81
fix typo
okozachenko1203 Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ __pycache__
dist
magnum_cluster_api/charts/*
!magnum_cluster_api/charts/.gitkeep
!magnum_cluster_api/charts/k8s-keystone-auth
site
23 changes: 23 additions & 0 deletions magnum_cluster_api/charts/k8s-keystone-auth/.helmignore
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/
8 changes: 8 additions & 0 deletions magnum_cluster_api/charts/k8s-keystone-auth/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: k8s-keystone-auth
description: A Helm chart for k8s-keystone-auth
type: application
version: 0.1.0
appVersion: v1.29.0
sources:
- https://github.com/kubernetes/cloud-provider-openstack/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Here is a reference https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/keystone-auth/using-keystone-webhook-authenticator-and-authorizer.md
62 changes: 62 additions & 0 deletions magnum_cluster_api/charts/k8s-keystone-auth/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "k8s-keystone-auth.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "k8s-keystone-auth.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "k8s-keystone-auth.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "k8s-keystone-auth.labels" -}}
helm.sh/chart: {{ include "k8s-keystone-auth.chart" . }}
{{ include "k8s-keystone-auth.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "k8s-keystone-auth.selectorLabels" -}}
app.kubernetes.io/name: {{ include "k8s-keystone-auth.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "k8s-keystone-auth.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "k8s-keystone-auth.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system:{{ include "k8s-keystone-auth.fullname" . }}
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- ""
resources:
- configmaps
- services
- pods
verbs:
- get
- list
- watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:{{ include "k8s-keystone-auth.fullname" . }}
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:{{ include "k8s-keystone-auth.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "k8s-keystone-auth.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "k8s-keystone-auth.fullname" . }}-policy
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
data:
policies: {{ toJson .Values.conf.policy | quote }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "k8s-keystone-auth.fullname" . }}-sync
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
data:
syncConfig: |
{{ .Values.conf.sync_config | indent 4 }}
100 changes: 100 additions & 0 deletions magnum_cluster_api/charts/k8s-keystone-auth/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "k8s-keystone-auth.fullname" . }}
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "k8s-keystone-auth.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "k8s-keystone-auth.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- ./bin/k8s-keystone-auth
- --tls-cert-file
- /etc/kubernetes/pki/apiserver.crt
- --tls-private-key-file
- /etc/kubernetes/pki/apiserver.key
- --policy-configmap-name
- {{ include "k8s-keystone-auth.fullname" . }}-policy
- --keystone-url
- {{ .Values.conf.auth_url }}
- --sync-configmap-name
- {{ include "k8s-keystone-auth.fullname" . }}-sync
{{- if not (empty .Values.conf.ca_cert) }}
- --keystone-ca-file
- /etc/kubernetes/cloud_ca.crt
{{- end }}
- --listen
- 127.0.0.1:8443
ports:
- name: https
containerPort: {{ .Values.service.port }}
hostPort: {{ .Values.service.hostPort }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if not (empty .Values.conf.ca_cert) }}
- mountPath: /etc/kubernetes/cloud_ca.crt
subPath: cloud_ca.crt
name: cloud-cert
readOnly: true
{{- end }}
- mountPath: /etc/kubernetes/pki
name: k8s-certs
readOnly: true
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
hostNetwork: true
volumes:
{{- if not (empty .Values.conf.ca_cert) }}
- name: cloud-cert
secret:
secretName: {{ include "k8s-keystone-auth.fullname" . }}-ca
defaultMode: 0444
{{- end }}
- hostPath:
path: /etc/kubernetes/pki
type: DirectoryOrCreate
name: k8s-certs
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if not (empty .Values.conf.ca_cert) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "k8s-keystone-auth.fullname" . }}-ca
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
stringData:
cloud_ca.crt: {{ .Values.conf.ca_cert }}
{{- end -}}
15 changes: 15 additions & 0 deletions magnum_cluster_api/charts/k8s-keystone-auth/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "k8s-keystone-auth.fullname" . }}
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
name: https
selector:
{{- include "k8s-keystone-auth.selectorLabels" . | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "k8s-keystone-auth.serviceAccountName" . }}
labels:
{{- include "k8s-keystone-auth.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
94 changes: 94 additions & 0 deletions magnum_cluster_api/charts/k8s-keystone-auth/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Default values for k8s-keystone-auth.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: registry.k8s.io/provider-os/k8s-keystone-auth
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

conf:
auth_url: http://keystone:5000/v3
# Specify the ca certificate body if needed.
ca_cert: ~
sync_config: |
role-mappings:
- keystone-role: member
groups: []
policy: ""


serviceAccount:
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}
podLabels: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 8443
hostPort: 8443

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

nodeSelector:
node-role.kubernetes.io/master: ""

tolerations:
# Make sure the pod can be scheduled on master kubelet.
- effect: NoSchedule
operator: Exists
# Mark the pod as a critical add-on for rescheduling.
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
operator: Exists

affinity: {}
Loading
Loading