Skip to content

Commit ab40421

Browse files
authored
Merge pull request #837 from MetaCell/feature/CH-240
CH-240: Implements support for authentication using service accounts for Docker registries hosted on Google Artifact Registry.
2 parents 0a25929 + 4670478 commit ab40421

24 files changed

Lines changed: 358 additions & 145 deletions

deployment-configuration/codefresh-template-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ steps:
3535
commands:
3636
- bash cloud-harness/install.sh
3737
- export HELM_META_ARGS="$( [ -n "${{HARNESS_CHART_NAME}}" ] && printf -- "--name %s " "${{HARNESS_CHART_NAME}}"; [ -n "${{HARNESS_CHART_VERSION}}" ] && printf -- "--chart-version %s " "${{HARNESS_CHART_VERSION}}"; [ -n "${{HARNESS_APP_VERSION}}" ] && printf -- "--app-version %s" "${{HARNESS_APP_VERSION}}" )"
38-
- harness-deployment $PATHS -d ${{DOMAIN}} -r ${{REGISTRY}} -rs '${{REGISTRY_SECRET}}' -n ${{NAMESPACE}} --write-env -e $ENV --cache-url '${{IMAGE_CACHE_URL}}' $HELM_META_ARGS $PARAMS
38+
- harness-deployment $PATHS -d ${{DOMAIN}} -r ${{REGISTRY}} -rsn '${{REGISTRY_SECRET}}' -n ${{NAMESPACE}} --write-env -e $ENV --cache-url '${{IMAGE_CACHE_URL}}' $HELM_META_ARGS $PARAMS
3939
- cat deployment/.env >> ${{CF_VOLUME_PATH}}/env_vars_to_export
4040
- cat ${{CF_VOLUME_PATH}}/env_vars_to_export
4141
prepare_deployment_view:

deployment-configuration/codefresh-template-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ steps:
3131
commands:
3232
- bash cloud-harness/install.sh
3333
- export HELM_META_ARGS="$( [ -n "${{HARNESS_CHART_NAME}}" ] && printf -- "--name %s " "${{HARNESS_CHART_NAME}}"; [ -n "${{HARNESS_CHART_VERSION}}" ] && printf -- "--chart-version %s " "${{HARNESS_CHART_VERSION}}"; [ -n "${{HARNESS_APP_VERSION}}" ] && printf -- "--app-version %s" "${{HARNESS_APP_VERSION}}" )"
34-
- harness-deployment $PATHS -t ${{DEPLOYMENT_TAG}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rs '${{REGISTRY_SECRET}}' -n ${{NAMESPACE}} -e $ENV --no-cd $HELM_META_ARGS $PARAMS
34+
- harness-deployment $PATHS -t ${{DEPLOYMENT_TAG}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rsn '${{REGISTRY_SECRET}}' -n ${{NAMESPACE}} -e $ENV --no-cd $HELM_META_ARGS $PARAMS
3535
prepare_deployment_view:
3636
commands:
3737
- "helm template ./deployment/helm --debug -n ${{NAMESPACE}}"

deployment-configuration/codefresh-template-stage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ steps:
3434
commands:
3535
- bash cloud-harness/install.sh
3636
- export HELM_META_ARGS="$( [ -n "${{HARNESS_CHART_NAME}}" ] && printf -- "--name %s " "${{HARNESS_CHART_NAME}}"; [ -n "${{HARNESS_CHART_VERSION}}" ] && printf -- "--chart-version %s " "${{HARNESS_CHART_VERSION}}"; [ -n "${{HARNESS_APP_VERSION}}" ] && printf -- "--app-version %s" "${{HARNESS_APP_VERSION}}" )"
37-
- harness-deployment $PATHS -t ${{DEPLOYMENT_TAG}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rs ${{REGISTRY_SECRET}} -n ${{NAMESPACE}} -e $ENV --no-cd $HELM_META_ARGS $PARAMS
37+
- harness-deployment $PATHS -t ${{DEPLOYMENT_TAG}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rsn ${{REGISTRY_SECRET}} -n ${{NAMESPACE}} -e $ENV --no-cd $HELM_META_ARGS $PARAMS
3838
prepare_deployment_view:
3939
commands:
4040
- "helm template ./deployment/helm --debug -n ${{NAMESPACE}}"

deployment-configuration/codefresh-template-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ steps:
3434
commands:
3535
- bash cloud-harness/install.sh
3636
- export HELM_META_ARGS="$( [ -n "${{HARNESS_CHART_NAME}}" ] && printf -- "--name %s " "${{HARNESS_CHART_NAME}}"; [ -n "${{HARNESS_CHART_VERSION}}" ] && printf -- "--chart-version %s " "${{HARNESS_CHART_VERSION}}"; [ -n "${{HARNESS_APP_VERSION}}" ] && printf -- "--app-version %s" "${{HARNESS_APP_VERSION}}" )"
37-
- harness-deployment $PATHS -n test-${{NAMESPACE_BASENAME}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rs ${{REGISTRY_SECRET}} -e $ENV --write-env --cache-url '${{IMAGE_CACHE_URL}}' -N $HELM_META_ARGS $PARAMS
37+
- harness-deployment $PATHS -n test-${{NAMESPACE_BASENAME}} -d ${{DOMAIN}} -r ${{REGISTRY}} -rsn ${{REGISTRY_SECRET}} -e $ENV --write-env --cache-url '${{IMAGE_CACHE_URL}}' -N $HELM_META_ARGS $PARAMS
3838
- cat deployment/.env >> ${{CF_VOLUME_PATH}}/env_vars_to_export
3939
- cat ${{CF_VOLUME_PATH}}/env_vars_to_export
4040
prepare_deployment_view:

deployment-configuration/helm/templates/auto-deployments.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
spec:
3333
{{- if and .root.Values.registry.secret (contains .root.Values.registry.name .app.harness.deployment.image) }}
3434
imagePullSecrets:
35-
- name: {{ .root.Values.registry.secret }}
35+
- name: {{ .root.Values.registry.secret.name }}
3636
{{- end }}
3737
{{- if and .app.harness.deployment.volume }}
3838
{{- if or (not (hasKey .app.harness.deployment.volume "usenfs")) (not .app.harness.deployment.volume.usenfs) }}

deployment-configuration/helm/templates/configmap.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ metadata:
1010
data:
1111
allvalues.yaml: |
1212
{{- $values_copy := deepCopy .Values }}
13+
{{- $registry := get $values_copy "registry" }}
14+
{{- if $registry }}
15+
{{- $secret := get $registry "secret" }}
16+
{{- if and (kindIs "map" $secret) (not (empty $secret.value)) }}
17+
{{- $tmp := set $registry "secret" nil }}
18+
{{- end }}
19+
{{- end }}
1320
{{- range $key, $val := .Values.apps }}
1421
{{- $app := get $values_copy.apps $key }}
1522
{{- $tmp := set $app.harness "secrets" dict }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if and .Values.registry.name .Values.registry.secret.name }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ .Values.registry.secret.name | quote }}
6+
namespace: {{ .Release.Namespace }}
7+
type: kubernetes.io/dockerconfigjson
8+
stringData:
9+
.dockerconfigjson: |-
10+
{
11+
"auths": {
12+
"{{ .Values.registry.name }}": {
13+
"username": "_json_key",
14+
"password": {{ .Values.registry.secret.value | toJson }},
15+
"auth": "{{ printf "_json_key:%s" .Values.registry.secret.value | b64enc }}"
16+
}
17+
}
18+
}
19+
{{- end }}

deployment-configuration/helm/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ registry:
1313
name: "localhost:5000"
1414
# -- Optional secret used for pulling from docker registry.
1515
secret:
16+
# -- Secret name used for pulling from docker registry.
17+
name:
18+
# -- Value of the secret used for pulling from docker registry in json encoded format.
19+
value:
1620
# -- Docker tag used to pull images.
1721
tag: latest
1822
# -- List of applications.
@@ -85,4 +89,4 @@ proxy:
8589
requests:
8690
memory: "32Mi"
8791
limits:
88-
memory: "64Mi"
92+
memory: "64Mi"

0 commit comments

Comments
 (0)