Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to specify registry credentials in values or via a premade secret. #18

Merged
merged 4 commits into from
Jul 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 1234@5678.com
```

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 @@ -68,6 +68,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 @@ -98,6 +105,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: 1234@5678.com

# If you don't want to put your passwords into a values file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add something about this to the README as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

# 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 @@ -70,6 +79,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 @@ -81,6 +94,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