Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
fix: properly checks presence of mounted secrets
Browse files Browse the repository at this point in the history
removes ns from kustomize resources as it will be anyway replaced when running the job
  • Loading branch information
bartoszmajsak committed Jun 28, 2023
1 parent 17d62c8 commit 83ea2e6
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 12 deletions.
16 changes: 12 additions & 4 deletions service-mesh/control-plane/base/init-job-rbac/job-rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: init-job-creator
namespace: istio-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: init-job-create
subjects:
- kind: ServiceAccount
name: init-job-executor
namespace: istio-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: init-job-reader
namespace: istio-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: init-job-read
subjects:
- kind: ServiceAccount
name: init-job-executor
namespace: istio-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: init-job-pod-executor
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: init-job-pod-operations
subjects:
- kind: ServiceAccount
name: init-job-executor
1 change: 0 additions & 1 deletion service-mesh/control-plane/base/init-job-rbac/job-sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: init-job-executor
namespace: istio-system
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: init-job-pod-operations
rules:
- apiGroups:
- ""
resources:
- pods/log
- pods/exec
verbs:
- get
- list
- create
- delete
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ rules:
verbs:
- create
- update
- patch
- patch
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ rules:
verbs:
- get
- watch
- list
- list
14 changes: 9 additions & 5 deletions service-mesh/control-plane/base/init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ spec:
# Ensure secrets are mounted in ingress-gateway. If not, restart the pod.
kubectl wait pods -l app=istio-ingressgateway --for condition=ready -n ${ISTIO_NAMESPACE}
if kubectl exec $(kubectl get pods -n ${ISTIO_NAMESPACE} \
-l app=istio-egressgateway \
-o jsonpath='{.items[*].metadata.name}') \
-n ${ISTIO_NAMESPACE} \
-c istio-proxy -- ls -al /etc/istio/odh-oauth2 2>&1 | grep -q 'No such file or directory'; then
INGRESS_POD=$(kubectl get pods -n ${ISTIO_NAMESPACE} -l app=istio-ingressgateway -o jsonpath='{.items[0].metadata.name}')
EXEC_OUTPUT=$(kubectl exec $INGRESS_POD -n ${ISTIO_NAMESPACE} -c istio-proxy -- ls -al /etc/istio/odh-oauth2/{token-secret.yaml,hmac-secret.yaml} 2>&1)
EXEC_EXIT_STATUS=$?
if echo $EXEC_OUTPUT | grep -q 'No such file or directory'; then
# If we don't see the secrets mounted, restart deployment.
kubectl rollout restart deployment -n ${ISTIO_NAMESPACE} istio-ingressgateway
elif [[ $EXEC_EXIT_STATUS -ne 0 ]]; then
echo "Failed with: $EXEC_OUTPUT"
exit 1
fi
exit 0
volumeMounts:
Expand Down
1 change: 1 addition & 0 deletions service-mesh/control-plane/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resources:
- init-job.yaml
- init-job-rbac/resource-read-roles.yaml
- init-job-rbac/resource-create-roles.yaml
- init-job-rbac/pod-executor-roles.yaml
- init-job-rbac/job-rolebinding.yaml
- init-job-rbac/job-sa.yaml
- cert-secret.yaml
Expand Down

0 comments on commit 83ea2e6

Please sign in to comment.