Skip to content
Snippets Groups Projects
Commit 4b474de3 authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Can provide credentials when image registry is private

parent a124de48
No related branches found
No related tags found
No related merge requests found
Pipeline #106326 passed
Pipeline: shiny-k8s-example

#106327

    ......@@ -15,7 +15,7 @@ type: application
    # This is the chart version. This version number should be incremented each time you make changes
    # to the chart and its templates, including the app version.
    # Versions are expected to follow Semantic Versioning (https://semver.org/)
    version: 0.2.2
    version: 0.3.0
    # This is the version number of the application being deployed. This version number should be
    # incremented each time you make changes to the application. Versions are not expected to
    ......
    {{- define "imagePullSecret" }}
    {{- if and .Values.registry .Values.registry.password .Values.registry.username .Values.registry.host }}
    {{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.registry.host (printf "%s:%s" .Values.registry.username .Values.registry.password | b64enc) | b64enc }}
    {{- else }}
    {{- required "When registry is private, you need to specify .Values.registry.password .Values.registry.username .Values.registry.host, see documetation for more." "" }}
    {{- end }}
    {{- end }}
    ......@@ -22,8 +22,10 @@ spec:
    labels:
    {{- include "chart.selectorLabels" . | nindent 8 }}
    spec:
    {{- if .Values.registry.private }}
    imagePullSecrets:
    - name: registry-gitlab
    - name: {{ include "chart.fullname" . }}
    {{- end }}
    containers:
    - name: rshiny-pod
    image: {{ .Values.imageFullNameAndTag }}
    ......
    {{- if .Values.registry.private }}
    # When creating a pod based on an image that resides in a private Docker registry (a secure registry protected by basic authentication),
    # one must specify an imagePullSecrets as part of the pod's spec.
    # (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-pod-that-uses-your-secret)
    # This resource creates a docker registry pull secret that's based on values provided in values.yaml (it relies on a template defined in _secretHelper.tpl). The secret must be deployed to
    # the same namespace in which the pod will be created.
    apiVersion: v1
    kind: Secret
    metadata:
    name : {{ include "chart.fullname" . }}
    type: kubernetes.io/dockerconfigjson
    data:
    .dockerconfigjson: {{ template "imagePullSecret" . }}
    {{- end }}
    ......@@ -29,3 +29,7 @@ ingress:
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/proxy-body-size: 256m
    hostname: ""
    registry:
    private: false
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment