Skip to content

Commit

Permalink
Merge pull request #18 from paulczar/repo-creds
Browse files Browse the repository at this point in the history
Allow user to specify registry credentials in values or via a premade secret.
  • Loading branch information
Vic Iglesias authored Jul 21, 2018
2 parents 1f30a21 + 40c50ac commit c43836b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
26 changes: 26 additions & 0 deletions stable/spinnaker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,32 @@ for Spinnaker. If you want to add arbitrary clusters need to do the following:
deploymentContext: my-context
```

## Specifying Docker Registries and Valid Images (Repositories)

Spinnaker will only give you access to Docker images that have been whitelisted, if you're using a private registry or a private repository you also need to provide credentials. Update the following values of the chart to do so:
```yaml
dockerRegistries:
- name: dockerhub
address: index.docker.io
repositories:
- library/alpine
- library/ubuntu
- library/centos
- library/nginx
# - name: gcr
# address: https://gcr.io
# username: _json_key
# password: '<INSERT YOUR SERVICE ACCOUNT JSON HERE>'
# email: [email protected]
```
You can provide passwords as a Helm value, or you can use a pre-created secret containing your registry passwords. The secret should have an item per Registry in the format: `<registry name>: <password>`. In which case you'll specify the secret to use in `dockerRegistryAccountSecret` like so:

```yaml
dockerRegistryAccountSecret: myregistry-secrets
```

## Customizing your installation

### Manual
Expand Down
13 changes: 12 additions & 1 deletion stable/spinnaker/templates/configmap/halyard-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
{{ include "spinnaker.standard-labels" . | indent 4 }}
data:
install.sh: |
#!/bin/bash
# Wait for the Hal daemon to be ready
export DAEMON_ENDPOINT=http://{{ template "spinnaker.fullname" . }}-halyard:8064
export HAL_COMMAND="hal --daemon-endpoint $DAEMON_ENDPOINT"
Expand Down Expand Up @@ -63,8 +65,17 @@ data:
PROVIDER_COMMAND='add'
fi
CREDS=""
{{ if $registry.username -}}
CREDS+="--username {{ $registry.username }} --password-file /opt/registry/passwords/{{ $registry.name }}"
{{ if $registry.email -}}
CREDS+=" --email {{ $registry.email }}"
{{- end -}}
{{- end }}
$HAL_COMMAND config provider docker-registry account $PROVIDER_COMMAND {{ $registry.name }} --address {{ $registry.address }} \
--repositories {{ range $index, $repository := $registry.repositories }}{{- $repository }},{{- end }}
${CREDS} --repositories {{ range $index, $repository := $registry.repositories }}{{if $index}},{{end}}{{- $repository }}{{- end }}
{{- end }}
$HAL_COMMAND config provider kubernetes enable
Expand Down
6 changes: 4 additions & 2 deletions stable/spinnaker/templates/secrets/registry.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.dockerRegistryAccountSecret }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -7,6 +8,7 @@ metadata:
component: clouddriver
type: Opaque
data:
{{- range $index, $account := .Values.accounts }}
password-{{ $account.name }}: {{ default "" $account.password | b64enc | quote }}
{{- range $index, $account := .Values.dockerRegistries }}
{{ $account.name }}: {{ default "" $account.password | b64enc | quote }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions stable/spinnaker/templates/statefulsets/halyard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ spec:
secret:
secretName: {{ template "spinnaker.fullname" . }}-gcs
{{- end }}
- name: reg-secrets
secret:
{{- if .Values.dockerRegistryAccountSecret }}
secretName: {{ .Values.dockerRegistryAccountSecret }}
{{- else }}
secretName: {{ template "spinnaker.fullname" .}}-registry
{{- end }}
{{- if and .Values.s3.enabled .Values.s3.accessKey .Values.s3.secretKey }}
- name: s3-secrets
secret:
Expand Down Expand Up @@ -82,6 +89,8 @@ spec:
mountPath: /home/spinnaker
- name: halyard-config
mountPath: /opt/halyard/config
- name: reg-secrets
mountPath: /opt/registry/passwords
volumeClaimTemplates:
- metadata:
name: halyard-home
Expand Down
16 changes: 16 additions & 0 deletions stable/spinnaker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ dockerRegistries:
# password: '<INSERT YOUR SERVICE ACCOUNT JSON HERE>'
# email: [email protected]

# If you don't want to put your passwords into a values file
# you can use a pre-created secret instead of putting passwords
# (specify secret name in below `dockerRegistryAccountSecret`)
# per account above with data in the format:
# <name>: <password>

# dockerRegistryAccountSecret: myregistry-secrets


kubeConfig:
# Use this when you want to register arbitrary clusters with Spinnaker
# Upload your ~/kube/.config to a secret
Expand Down Expand Up @@ -78,6 +87,10 @@ redis:
nodeSelector: {}
cluster:
enabled: false
# Uncomment if you don't want to create a PVC for redis
# master:
# persistence:
# enabled: false

# Minio access/secret keys for the in-cluster S3 usage
# Minio is not exposed publically
Expand All @@ -89,6 +102,9 @@ minio:
secretKey: spinnakeradmin
bucket: "spinnaker"
nodeSelector: {}
# Uncomment if you don't want to create a PVC for minio
# persistence:
# enabled: false

gcs:
enabled: false
Expand Down

0 comments on commit c43836b

Please sign in to comment.