Skip to content

Commit

Permalink
feat: ✨ arbitrary values can be passed to helm harbor
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudTA committed Jun 2, 2023
1 parent 54121ae commit 82ba737
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 90 deletions.
96 changes: 6 additions & 90 deletions roles/harbor/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,103 +37,19 @@

- name: Set harbor helm values
ansible.builtin.set_fact:
harbor_values: |
expose:
type: ingress
tls:
enabled: true
{% if ingress.tls.type == 'tlsSecret' %}
certSource: secret
secret:
secretName: {{ ingress.tls.tlsSecret.name }}
notarySecretName: {{ ingress.tls.tlsSecret.name }}
{% else %}
certSource: null
secret: {}
{% endif %}
ingress:
hosts:
core: {{ HARBOR_DOMAIN }}
notary: notary{{ ROOT_DOMAIN }}
notary:
annotations:
{% for key, val in ingress.annotations.items() %}
{{ key }}: {{ val }}
{% endfor %}
labels:
{% for key, val in ingress.labels.items() %}
{{ key }}: {{ val }}
{% endfor %}
harbor:
annotations:
{% for key, val in ingress.annotations.items() %}
{{ key }}: {{ val }}
{% endfor %}
labels:
{% for key, val in ingress.labels.items() %}
{{ key }}: {{ val }}
{% endfor %}
externalURL: https://{{ HARBOR_DOMAIN }}
persistence:
enabled: true
resourcePolicy: keep
harborAdminPassword: "{{ HARBOR_ADMIN_PASSWORD }}"
nginx:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/nginx-photon
portal:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-portal
core:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-core
jobservice:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-jobservice
registry:
serviceAccountName: harbor-sa
registry:
image:
repository: docker.io/goharbor/registry-photon
controller:
image:
repository: docker.io/goharbor/harbor-registryctl
chartmuseum:
serviceAccountName: harbor-sa
trivy:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/trivy-adapter-photon
notary:
server:
serviceAccountName: harbor-sa
signer:
serviceAccountName: harbor-sa
database:
internal:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-db
redis:
internal:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/redis-photon
exporter:
image:
repository: docker.io/goharbor/harbor-exporter
harbor_values: "{{ lookup('template', 'values.yaml.j2') | from_yaml }}"

- name: Merge with harbor user values
set_fact:
harbor_values: "{{ harbor_values | combine(HARBOR_VALUES, recursive=True) }}"

- name: Deploy helm
kubernetes.core.helm:
name: harbor
chart_ref: harbor/harbor
chart_version: "1.12.0"
release_namespace: "{{ HARBOR_NAMESPACE }}"
values: "{{ helm_values | from_yaml }}"
values: "{{ harbor_values }}"

- name: Update inventory
kubernetes.core.k8s:
Expand Down
88 changes: 88 additions & 0 deletions roles/harbor/templates/values.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
expose:
type: ingress
tls:
enabled: true
{% if ingress.tls.type == 'tlsSecret' %}
certSource: secret
secret:
secretName: {{ ingress.tls.tlsSecret.name }}
notarySecretName: {{ ingress.tls.tlsSecret.name }}
{% else %}
certSource: null
secret: {}
{% endif %}
ingress:
hosts:
core: {{ HARBOR_DOMAIN }}
notary: notary{{ ROOT_DOMAIN }}
notary:
annotations:
{% for key, val in ingress.annotations.items() %}
{{ key }}: {{ val }}
{% endfor %}
labels:
{% for key, val in ingress.labels.items() %}
{{ key }}: {{ val }}
{% endfor %}
harbor:
annotations:
{% for key, val in ingress.annotations.items() %}
{{ key }}: {{ val }}
{% endfor %}
labels:
{% for key, val in ingress.labels.items() %}
{{ key }}: {{ val }}
{% endfor %}
externalURL: https://{{ HARBOR_DOMAIN }}
persistence:
enabled: true
resourcePolicy: keep
harborAdminPassword: "{{ HARBOR_ADMIN_PASSWORD }}"
nginx:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/nginx-photon
portal:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-portal
core:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-core
jobservice:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-jobservice
registry:
serviceAccountName: harbor-sa
registry:
image:
repository: docker.io/goharbor/registry-photon
controller:
image:
repository: docker.io/goharbor/harbor-registryctl
chartmuseum:
serviceAccountName: harbor-sa
trivy:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/trivy-adapter-photon
notary:
server:
serviceAccountName: harbor-sa
signer:
serviceAccountName: harbor-sa
database:
internal:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/harbor-db
redis:
internal:
serviceAccountName: harbor-sa
image:
repository: docker.io/goharbor/redis-photon
exporter:
image:
repository: docker.io/goharbor/harbor-exporte
3 changes: 3 additions & 0 deletions roles/socle-config/files/socle-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ GITLAB_VALUES: {}
HARBOR_NAMESPACE: harbor-system
HARBOR_DOMAIN: harbor{{ ROOT_DOMAIN }}
HARBOR_ADMIN_PASSWORD: MySuperPassword
# You can merge customs values for harbor, it will be merged with roles/harbor/tasks/main.yaml
# See https://github.com/goharbor/harbor-helm
HARBOR_VALUES: {}

# KEYCLOAK
KEYCLOAK_NAMESPACE: keycloak-system
Expand Down

0 comments on commit 82ba737

Please sign in to comment.