Skip to content

Commit

Permalink
alauda changes
Browse files Browse the repository at this point in the history
  • Loading branch information
airycanon committed Sep 12, 2024
1 parent 126d130 commit c624be4
Show file tree
Hide file tree
Showing 18 changed files with 421 additions and 67 deletions.
8 changes: 7 additions & 1 deletion templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ app: "{{ template "harbor.name" . }}"
{{- define "harbor.redis.url" -}}
{{- with .Values.redis }}
{{- $path := ternary "" (printf "/%s" (include "harbor.redis.masterSet" $)) (not (include "harbor.redis.masterSet" $)) }}
{{- printf "%s://%s%s%s" (include "harbor.redis.scheme" $) (include "harbor.redis.cred" $) (include "harbor.redis.addr" $) $path -}}
{{- if eq .type "internal" }}
{{- $cred := ternary (printf ":%s@" (.internal.password | urlquery)) "" .internal.usePassword }}
{{- printf "%s://%s%s%s" (include "harbor.redis.scheme" $) $cred (include "harbor.redis.addr" $) $path -}}
{{- else }}
{{- $cred := ternary (printf ":%s@" (.external.password | urlquery)) "" (and (eq .type "external" ) (not (not .external.password))) }}
{{- printf "%s://%s%s%s" (include "harbor.redis.scheme" $) $cred (include "harbor.redis.addr" $) $path -}}
{{- end }}
{{- end }}
{{- end -}}

Expand Down
4 changes: 2 additions & 2 deletions templates/core/core-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ data:
{{- end }}
{{- if or (and (eq .Values.redis.type "internal") .Values.redis.internal.cacheLayerDatabaseIndex) (and (eq .Values.redis.type "external") .Values.redis.external.cacheLayerDatabaseIndex) }}
_REDIS_URL_CACHE_LAYER: "{{ template "harbor.redis.urlForCache" . }}"
{{- end }}
{{- end }}
PORTAL_URL: "{{ template "harbor.portalURL" . }}"
REGISTRY_CONTROLLER_URL: "{{ template "harbor.registryControllerURL" . }}"
REGISTRY_CREDENTIAL_USERNAME: "{{ .Values.registry.credentials.username }}"
Expand Down Expand Up @@ -84,7 +84,7 @@ data:
CACHE_ENABLED: "true"
CACHE_EXPIRE_HOURS: "{{ .Values.cache.expireHours }}"
{{- end }}

{{- if .Values.core.quotaUpdateProvider }}
QUOTA_UPDATE_PROVIDER: "{{ .Values.core.quotaUpdateProvider }}"
{{- end }}
21 changes: 12 additions & 9 deletions templates/core/core-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ spec:
envFrom:
- configMapRef:
name: "{{ template "harbor.core" . }}"
- secretRef:
name: "{{ template "harbor.core" . }}"
env:
- name: CORE_SECRET
valueFrom:
Expand All @@ -109,13 +107,6 @@ spec:
{{- else }}
key: JOBSERVICE_SECRET
{{- end }}
{{- if .Values.existingSecretAdminPassword }}
- name: HARBOR_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.existingSecretAdminPassword }}
key: {{ .Values.existingSecretAdminPasswordKey }}
{{- end }}
{{- if .Values.internalTLS.enabled }}
- name: INTERNAL_TLS_ENABLED
value: "true"
Expand Down Expand Up @@ -156,6 +147,8 @@ spec:
ports:
- containerPort: {{ template "harbor.core.containerPort" . }}
volumeMounts:
- name: env-files
mountPath: /etc/env-files
- name: config
mountPath: /etc/core/app.conf
subPath: app.conf
Expand Down Expand Up @@ -188,6 +181,16 @@ spec:
{{ toYaml .Values.core.resources | indent 10 }}
{{- end }}
volumes:
- emptyDir: {}
name: env-files
- name: core-secret
secret:
secretName: "{{ template "harbor.core" . }}"
{{- if .Values.harborAdminPasswordRef }}
- name: core-admin-secret
secret:
secretName: {{ .Values.harborAdminPasswordRef | quote }}
{{- end }}
- name: config
configMap:
name: {{ template "harbor.core" . }}
Expand Down
5 changes: 3 additions & 2 deletions templates/core/core-pre-upgrade-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: migration-job
name: {{ template "harbor.core" . }}-migration-job
labels:
{{ include "harbor.labels" . | indent 4 }}
component: migrator
Expand All @@ -12,6 +12,7 @@ metadata:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "-5"
spec:
ttlSecondsAfterFinished: 300
template:
metadata:
labels:
Expand All @@ -32,7 +33,7 @@ spec:
terminationGracePeriodSeconds: 120
containers:
- name: core-job
image: {{ .Values.core.image.repository }}:{{ .Values.core.image.tag }}
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.core.repository }}:{{ .Values.global.images.core.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
command: ["/harbor/harbor_core", "-mode=migrate"]
envFrom:
Expand Down
6 changes: 5 additions & 1 deletion templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ spec:
{{- end }}
containers:
- name: exporter
image: {{ .Values.exporter.image.repository }}:{{ .Values.exporter.image.tag }}
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.exporter.repository }}:{{ .Values.global.images.exporter.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
livenessProbe:
httpGet:
Expand All @@ -78,6 +78,10 @@ spec:
name: "{{ template "harbor.exporter" . }}-env"
- secretRef:
name: "{{ template "harbor.exporter" . }}"
{{- if .Values.harborAdminPasswordRef }}
- secretRef:
name: {{ .Values.harborAdminPasswordRef | quote }}
{{- end }}
env:
{{- if .Values.database.external.existingSecret }}
- name: HARBOR_DATABASE_PASSWORD
Expand Down
3 changes: 3 additions & 0 deletions templates/ingress/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ metadata:
{{ toYaml $ingress.labels | indent 4 }}
{{- end }}
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}, {"HTTP":80}]'
{{ toYaml $ingress.annotations | indent 4 }}
{{- if .Values.internalTLS.enabled }}
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
Expand Down
4 changes: 2 additions & 2 deletions templates/ingress/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if eq (include "harbor.autoGenCertForIngress" .) "true" }}
{{- $ca := genCA "harbor-ca" 365 }}
{{- $cert := genSignedCert .Values.expose.ingress.hosts.core nil (list .Values.expose.ingress.hosts.core) 365 $ca }}
{{- $ca := genCA "harbor-ca" 3650 }}
{{- $cert := genSignedCert .Values.expose.ingress.hosts.core nil (list .Values.expose.ingress.hosts.core .Values.expose.ingress.hosts.notary) 3650 $ca }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
10 changes: 5 additions & 5 deletions templates/internal/auto-tls.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{- if and .Values.internalTLS.enabled (eq .Values.internalTLS.certSource "auto") }}
{{- $ca := genCA "harbor-internal-ca" 365 }}
{{- $ca := genCA "harbor-internal-ca" 3650 }}
{{- $coreCN := (include "harbor.core" .) }}
{{- $coreCrt := genSignedCert $coreCN (list "127.0.0.1") (list "localhost" $coreCN) 365 $ca }}
{{- $coreCrt := genSignedCert $coreCN (list "127.0.0.1") (list "localhost" $coreCN) 3650 $ca }}
{{- $jsCN := (include "harbor.jobservice" .) }}
{{- $jsCrt := genSignedCert $jsCN nil (list $jsCN) 365 $ca }}
{{- $jsCrt := genSignedCert $jsCN nil (list $jsCN) 3650 $ca }}
{{- $regCN := (include "harbor.registry" .) }}
{{- $regCrt := genSignedCert $regCN nil (list $regCN) 365 $ca }}
{{- $regCrt := genSignedCert $regCN nil (list $regCN) 3650 $ca }}
{{- $portalCN := (include "harbor.portal" .) }}
{{- $portalCrt := genSignedCert $portalCN nil (list $portalCN) 365 $ca }}
{{- $portalCrt := genSignedCert $portalCN nil (list $portalCN) 3650 $ca }}

---
apiVersion: v1
Expand Down
60 changes: 56 additions & 4 deletions templates/jobservice/jobservice-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ spec:
{{ toYaml .Values.jobservice.podAnnotations | indent 8 }}
{{- end }}
spec:
initContainers:
- name: prepare-env-files
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.initContainer.repository }}:{{ .Values.global.images.initContainer.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- if .Values.core.resources }}
resources:
{{ toYaml .Values.core.resources | indent 10 }}
{{- end }}
command:
- sh
- -c
- |
set -e
cp -v /etc/jobservice-secret/* /etc/env-files/
volumeMounts:
- mountPath: /etc/env-files
name: env-files
- mountPath: /etc/jobservice-secret
name: jobservice-secret
- name: "change-permission"
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.initContainer.repository }}:{{ .Values.global.images.initContainer.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- if .Values.jobservice.resources }}
resources:
{{ toYaml .Values.jobservice.resources | indent 10 }}
{{- end }}
command: ["/bin/sh"]
args: ["-c", "if ! stat -c '%u:%g' /var/log/jobs/ | grep -q '10000:10000'; then chown -R 10000:10000 /var/log/jobs/; fi"]
securityContext:
runAsUser: 0
volumeMounts:
- name: job-logs
mountPath: /var/log/jobs
subPath: {{ .Values.persistence.persistentVolumeClaim.jobservice.subPath }}
securityContext:
runAsUser: 10000
fsGroup: 10000
Expand Down Expand Up @@ -69,7 +103,7 @@ spec:
{{- end }}
containers:
- name: jobservice
image: {{ .Values.jobservice.image.repository }}:{{ .Values.jobservice.image.tag }}
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.jobservice.repository }}:{{ .Values.global.images.jobservice.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
livenessProbe:
httpGet:
Expand Down Expand Up @@ -128,11 +162,11 @@ spec:
envFrom:
- configMapRef:
name: "{{ template "harbor.jobservice" . }}-env"
- secretRef:
name: "{{ template "harbor.jobservice" . }}"
ports:
- containerPort: {{ template "harbor.jobservice.containerPort" . }}
volumeMounts:
- name: env-files
mountPath: /etc/env-files
- name: jobservice-config
mountPath: /etc/jobservice/config.yml
subPath: config.yml
Expand All @@ -147,16 +181,27 @@ spec:
{{ include "harbor.caBundleVolumeMount" . | indent 8 }}
{{- end }}
volumes:
- emptyDir: {}
name: env-files
- name: jobservice-secret
secret:
secretName: "{{ template "harbor.jobservice" . }}"
- name: jobservice-config
configMap:
name: "{{ template "harbor.jobservice" . }}"
- name: job-logs
{{- if and .Values.persistence.enabled (has "file" .Values.jobservice.jobLoggers) }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.persistentVolumeClaim.jobservice.jobLog.existingClaim | default (include "harbor.jobservice" .) }}
claimName: {{ .Values.persistence.persistentVolumeClaim.jobservice.existingClaim | default (include "harbor.jobservice" .) }}
{{- else }}
{{- if and (.Values.persistence.hostPath.jobservice.host.nodeName) (.Values.persistence.hostPath.jobservice.host.path) }}
hostPath:
path: {{ .Values.persistence.hostPath.jobservice.host.path }}
type: DirectoryOrCreate
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- if .Values.internalTLS.enabled }}
- name: jobservice-internal-certs
secret:
Expand All @@ -165,9 +210,16 @@ spec:
{{- if .Values.caBundleSecretName }}
{{ include "harbor.caBundleVolume" . | indent 6 }}
{{- end }}
{{- if .Values.jobservice.nodeSelector }}
{{- with .Values.jobservice.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- else }}
{{- if .Values.persistence.hostPath.jobservice.host.nodeName }}
nodeSelector:
kubernetes.io/hostname: {{ .Values.persistence.hostPath.jobservice.host.nodeName }}
{{- end }}
{{- end }}
{{- with .Values.jobservice.affinity }}
affinity:
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
{{- end }}
containers:
- name: nginx
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
image: "{{ .Values.global.registry.address }}/{{ .Values.global.images.nginx.repository }}:{{ .Values.global.images.nginx.tag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
{{- $_ := set . "scheme" "HTTP" -}}
{{- $_ := set . "port" "8080" -}}
Expand Down
6 changes: 3 additions & 3 deletions templates/nginx/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if eq (include "harbor.autoGenCertForNginx" .) "true" }}
{{- $ca := genCA "harbor-ca" 365 }}
{{- $ca := genCA "harbor-ca" 3650 }}
{{- $cn := (required "The \"expose.tls.auto.commonName\" is required!" .Values.expose.tls.auto.commonName) }}
apiVersion: v1
kind: Secret
Expand All @@ -10,12 +10,12 @@ metadata:
type: Opaque
data:
{{- if regexMatch `^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$` $cn }}
{{- $cert := genSignedCert $cn (list $cn) nil 365 $ca }}
{{- $cert := genSignedCert $cn (list $cn) nil 3650 $ca }}
tls.crt: {{ $cert.Cert | b64enc | quote }}
tls.key: {{ $cert.Key | b64enc | quote }}
ca.crt: {{ $ca.Cert | b64enc | quote }}
{{- else }}
{{- $cert := genSignedCert $cn nil (list $cn) 365 $ca }}
{{- $cert := genSignedCert $cn nil (list $cn) 3650 $ca }}
tls.crt: {{ $cert.Cert | b64enc | quote }}
tls.key: {{ $cert.Key | b64enc | quote }}
ca.crt: {{ $ca.Cert | b64enc | quote }}
Expand Down
6 changes: 3 additions & 3 deletions templates/nginx/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Service
metadata:
{{- if eq .Values.expose.type "clusterIP" }}
{{- $clusterIP := .Values.expose.clusterIP }}
name: {{ $clusterIP.name }}
name: {{ template "harbor.fullname" .}}-{{ $clusterIP.name }}
labels:
{{ include "harbor.labels" . | indent 4 }}
{{- if .Values.expose.clusterIP.labels }}
Expand All @@ -30,7 +30,7 @@ spec:
{{- end }}
{{- else if eq .Values.expose.type "nodePort" }}
{{- $nodePort := .Values.expose.nodePort }}
name: {{ $nodePort.name }}
name: {{ template "harbor.fullname" .}}-{{ $nodePort.name }}
labels:
{{ include "harbor.labels" . | indent 4 }}
{{- if .Values.expose.nodePort.labels }}
Expand Down Expand Up @@ -59,7 +59,7 @@ spec:
{{- end }}
{{- else if eq .Values.expose.type "loadBalancer" }}
{{- $loadBalancer := .Values.expose.loadBalancer }}
name: {{ $loadBalancer.name }}
name: {{ template "harbor.fullname" .}}-{{ $loadBalancer.name }}
labels:
{{ include "harbor.labels" . | indent 4 }}
{{- if .Values.expose.loadBalancer.labels }}
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions templates/portal/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ data:
location /devcenter-api-2.0 {
try_files $uri $uri/ /swagger-ui-index.html;
}
{{- if not .Values.portal.swagger.enabled }}
location = /swagger.json {
return 404;
}
location = /swagger.yaml {
return 404;
}
{{- end }}
location / {
try_files $uri $uri/ /index.html;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/portal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ spec:
{{- end }}
containers:
- name: portal
image: {{ .Values.portal.image.repository }}:{{ .Values.portal.image.tag }}
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.portal.repository }}:{{ .Values.global.images.portal.tag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- if .Values.portal.resources }}
resources:
Expand Down
Loading

0 comments on commit c624be4

Please sign in to comment.