-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support keystone-auth * render template * fix unittest * fix flake and isort issue * fix manifest path * fix jinja env initi * fix calico path * fix flake8 error * Configuration on K8S master for authentication and/or authorization * fix lint errors * workaround for jsonpath for slices * add missing webhook file content * mount cloud ca in keystone-webhook for tls support and add /v3 in identity url * fix indentation * support http endpoints * write k8s-keystone-auth helm chart and use helm template * revert manifest changes * fix template output * set namespace for helm template rendered manifests * set ca cert optionally * set hostnetwork in keystone-auth chart * fix helm template rendering * fix volume mount * fix lint errors * remove static manifests * add webhook file * resolve comments * fix typo --------- Co-authored-by: okozachenko1203 <[email protected]>
- Loading branch information
1 parent
1a440fc
commit 50a2c27
Showing
18 changed files
with
590 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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/ |
This file contains 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: 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/ |
1 change: 1 addition & 0 deletions
1
magnum_cluster_api/charts/k8s-keystone-auth/templates/NOTES.txt
This file contains 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 @@ | ||
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
62
magnum_cluster_api/charts/k8s-keystone-auth/templates/_helpers.tpl
This file contains 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,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 }} |
21 changes: 21 additions & 0 deletions
21
magnum_cluster_api/charts/k8s-keystone-auth/templates/clusterrole.yaml
This file contains 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,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 |
19 changes: 19 additions & 0 deletions
19
magnum_cluster_api/charts/k8s-keystone-auth/templates/clusterrolebinding.yaml
This file contains 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,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 }} |
8 changes: 8 additions & 0 deletions
8
magnum_cluster_api/charts/k8s-keystone-auth/templates/configmap-policy.yaml
This file contains 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: ConfigMap | ||
metadata: | ||
name: {{ include "k8s-keystone-auth.fullname" . }}-policy | ||
labels: | ||
{{- include "k8s-keystone-auth.labels" . | nindent 4 }} | ||
data: | ||
policies: {{ toJson .Values.conf.policy | quote }} |
9 changes: 9 additions & 0 deletions
9
magnum_cluster_api/charts/k8s-keystone-auth/templates/configmap-sync.yaml
This file contains 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,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
100
magnum_cluster_api/charts/k8s-keystone-auth/templates/daemonset.yaml
This file contains 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,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 }} |
10 changes: 10 additions & 0 deletions
10
magnum_cluster_api/charts/k8s-keystone-auth/templates/secret-ca.yaml
This file contains 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,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
15
magnum_cluster_api/charts/k8s-keystone-auth/templates/service.yaml
This file contains 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,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 }} |
11 changes: 11 additions & 0 deletions
11
magnum_cluster_api/charts/k8s-keystone-auth/templates/serviceaccount.yaml
This file contains 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,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 }} |
This file contains 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,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: {} |
Oops, something went wrong.