Skip to content

Commit

Permalink
Merge pull request #36 from thedadams/use-c_rehash
Browse files Browse the repository at this point in the history
Run c_rehash before launching the operator
  • Loading branch information
Donnie Adams authored Jul 13, 2021
2 parents 8678208 + 14f8f6d commit ea1c80d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
13 changes: 12 additions & 1 deletion charts/aks-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ spec:
ke.cattle.io/operator: aks
spec:
serviceAccountName: aks-operator
securityContext:
fsGroup: 1007
runAsUser: 1007
containers:
- name: aks-operator
image: {{ template "system_default_registry" . }}{{ .Values.aksOperator.image.repository }}:{{ .Values.aksOperator.image.tag }}
Expand All @@ -26,8 +29,16 @@ spec:
- name: NO_PROXY
value: {{ .Values.noProxy }}
{{- if .Values.additionalTrustedCAs }}
# aks-operator mounts the additional CAs in two places:
volumeMounts:
- mountPath: /etc/ssl/certs/ca-additional.pem
# This directory is owned by the aks-operator user so c_rehash works here.
- mountPath: /etc/rancher/ssl/ca-additional.pem
name: tls-ca-additional-volume
subPath: ca-additional.pem
readOnly: true
# This directory is root-owned so c_rehash doesn't work here,
# but the cert is here in case update-ca-certificates is called in the future or by the OS.
- mountPath: /etc/pki/trust/anchors/ca-additional.pem
name: tls-ca-additional-volume
subPath: ca-additional.pem
readOnly: true
Expand Down
10 changes: 9 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ RUN zypper update -y && \
rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/*
RUN useradd --uid 1007 aks-operator
ENV KUBECONFIG /home/aks-operator/.kube/config
ENV SSL_CERT_DIR /etc/rancher/ssl

COPY bin/aks-operator /usr/bin/
COPY package/entrypoint.sh /usr/bin
RUN chmod +x /usr/bin/entrypoint.sh

RUN mkdir -p /etc/rancher/ssl && \
chown -R aks-operator /etc/rancher/ssl

USER 1007
ENTRYPOINT ["aks-operator"]
ENTRYPOINT ["entrypoint.sh"]
9 changes: 9 additions & 0 deletions package/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

if [ -x "$(command -v c_rehash)" ]; then
# c_rehash is run here instead of update-ca-certificates because the latter requires root privileges
# and the aks-operator container is run as non-root user.
c_rehash
fi
aks-operator

0 comments on commit ea1c80d

Please sign in to comment.