Skip to content

Commit

Permalink
Merge pull request #6 from ccojocar/dex_grpc_client
Browse files Browse the repository at this point in the history
feat:(dex grpc) add gRPC client for dex server
  • Loading branch information
Cosmin Cojocar authored Jul 27, 2018
2 parents e431691 + f54795b commit 5c69384
Show file tree
Hide file tree
Showing 11 changed files with 390 additions and 6 deletions.
83 changes: 82 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ codegen:
@echo "GENERATING KUBERNETES CRDs"
hack/update-codegen.sh

linux:
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)

watch:
reflex -r "\.go$" -R "vendor.*" make skaffold-run

Expand Down
20 changes: 20 additions & 0 deletions charts/sso-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/sso-operator"]
args:
- "--dex-grpc-host-port={{ .Values.dex.grpcHostAndPort }}"
- "--dex-grpc-ca=/etc/dex/ca/ca.crt"
- "--dex-grpc-client-crt=/etc/dex/tls/tls.crt"
- "--dex-grpc-client-key=/etc/dex/tls/tls.key"
env:
- name: OPERATOR_NAMESPACE
value: {{ .Release.Namespace }}
volumeMounts:
- name: dex-grpc-ca
mountPath: /etc/dex/ca
- name: dex-grpc-client-tls
mountPath: /etc/dex/tls
ports:
- containerPort: {{ .Values.service.internalPort }}
livenessProbe:
Expand All @@ -44,4 +55,13 @@ spec:
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
volumes:
- name: dex-grpc-ca
configMap:
name: {{ .Values.dex.certs.grpcCA }}
- name: dex-grpc-client-tls
secret:
defaultMode: 420
secretName: {{ .Values.dex.certs.grpcClientTls }}

terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
43 changes: 43 additions & 0 deletions charts/sso-operator/templates/job-install-grpc-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.dex.certs.install.create }}
{{ $caName := .Values.dex.certs.grpcCA }}
{{ $clientTlsSecretName := .Values.dex.certs.grpcClientTls }}
{{ $sourceNamespace := .Values.dex.certs.install.sourceNamespace }}
apiVersion: batch/v1
kind: Job
metadata:
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "4"
"helm.sh/hook-delete-policy": hook-succeeded
name: job-install-grpc-secrets
labels:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
activeDeadlineSeconds: {{ .Values.dex.certs.install.activeDeadlineSeconds }}
template:
metadata:
labels:
release: "{{ .Release.Name }}"
component: "job"
spec:
serviceAccountName: {{ template "fullname" . }}-install-certs
restartPolicy: OnFailure
containers:
- name: main
image: "{{ .Values.dex.certs.install.image }}:{{ .Values.dex.certs.install.imageTag }}"
imagePullPolicy: {{ .Values.dex.certs.install.imagePullPolicy }}
command:
- /bin/bash
- -exc
- |
# Cleanup the existing config map and secrets
kubectl delete configmap {{ $caName }} --namespace {{ .Release.Namespace }} || true
kubectl delete secret {{ $clientTlsSecretName }} --namespace {{ .Release.Namespace }} || true
# Copy the secrts from source namespace
kubectl get secret {{ $clientTlsSecretName }} --namespace={{ $sourceNamespace }} --export -o yaml |\
kubectl apply --namespace={{ .Release.Namespace }} -f -
kubectl get cm {{ $caName }} --namespace={{ $sourceNamespace }} --export -o yaml |\
kubectl apply --namespace={{ .Release.Namespace }} -f -
{{- end }}
16 changes: 16 additions & 0 deletions charts/sso-operator/templates/role-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.dex.certs.install.create }}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "2"
"helm.sh/hook-delete-policy": hook-succeeded
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
name: {{ template "fullname" . }}-install-certs
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
verbs: ["*"]
{{- end }}
22 changes: 22 additions & 0 deletions charts/sso-operator/templates/rolebinding-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.dex.certs.install.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "3"
"helm.sh/hook-delete-policy": hook-succeeded
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
name: {{ template "fullname" . }}-install-certs
namespace: {{ .Values.dex.certs.install.sourceNamespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "fullname" . }}-install-certs
subjects:
- kind: ServiceAccount
name: {{ template "fullname" . }}-install-certs
namespace: {{ .Release.Namespace }}

{{- end }}
14 changes: 14 additions & 0 deletions charts/sso-operator/templates/sa-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.dex.certs.install.create }}
kind: ServiceAccount
apiVersion: v1
metadata:
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": hook-succeeded
name: {{ template "fullname" . }}-install-certs
namespace: {{ .Release.Namespace }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- end }}

13 changes: 13 additions & 0 deletions charts/sso-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ readinessProbe:
successThreshold: 1
timeoutSeconds: 1
terminationGracePeriodSeconds: 10

dex:
grpcHostAndPort: dex:5000
certs:
grpcCA: dex-grpc-ca
grpcClientTls: dex-grpc-client-tls
install:
create: true
image: gcr.io/google_containers/kubernetes-dashboard-init-amd64
imageTag: "v1.0.0"
imagePullPolicy: "IfNotPresent"
sourceNamespace: jx
activeDeadlineSeconds: 300
Loading

0 comments on commit 5c69384

Please sign in to comment.