Skip to content

Commit 43a050e

Browse files
ferruhcihanElderMattj-zimnowoda
authored
feat: harbor app operator (#1628)
Co-authored-by: ElderMatt <[email protected]> Co-authored-by: Jehoszafat Zimnowoda <[email protected]>
1 parent 89e03c5 commit 43a050e

15 files changed

+367
-61
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/apl-harbor-operator/Chart.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: apl-harbor-operator
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The apl-harbor-operator has been deployed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "apl-harbor-operator.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "apl-harbor-operator.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "apl-harbor-operator.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "apl-harbor-operator.labels" -}}
37+
helm.sh/chart: {{ include "apl-harbor-operator.chart" . }}
38+
{{ include "apl-harbor-operator.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "apl-harbor-operator.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "apl-harbor-operator.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "apl-harbor-operator.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "apl-harbor-operator.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "apl-harbor-operator.fullname" . }}
5+
labels:
6+
{{- include "apl-harbor-operator.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "apl-harbor-operator.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "apl-harbor-operator.labels" . | nindent 8 }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
serviceAccountName: {{ include "apl-harbor-operator.serviceAccountName" . }}
26+
securityContext:
27+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
securityContext:
31+
{{- toYaml .Values.securityContext | nindent 12 }}
32+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
33+
imagePullPolicy: {{ .Values.image.pullPolicy }}
34+
command: [npm, run, operator:harbor]
35+
env:
36+
- name: DEBUG
37+
value: "{{ .Values.env.DEBUG }}"
38+
- name: HARBOR_BASE_URL
39+
value: "{{ .Values.env.HARBOR_BASE_URL }}"
40+
- name: HARBOR_BASE_URL_PORT
41+
value: "{{ .Values.env.HARBOR_BASE_URL_PORT }}"
42+
- name: HARBOR_OPERATOR_NAMESPACE
43+
value: "{{ .Values.env.HARBOR_OPERATOR_NAMESPACE }}"
44+
- name: HARBOR_SYSTEM_NAMESPACE
45+
value: "{{ .Values.env.HARBOR_SYSTEM_NAMESPACE }}"
46+
resources:
47+
{{- toYaml .Values.resources | nindent 12 }}
48+
{{- with .Values.nodeSelector }}
49+
nodeSelector:
50+
{{- toYaml . | nindent 8 }}
51+
{{- end }}
52+
{{- with .Values.affinity }}
53+
affinity:
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}
56+
{{- with .Values.tolerations }}
57+
tolerations:
58+
{{- toYaml . | nindent 8 }}
59+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{- if .Values.serviceAccount.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "apl-harbor-operator.serviceAccountName" . }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
automountServiceAccountToken: true
8+
---
9+
apiVersion: rbac.authorization.k8s.io/v1
10+
kind: ClusterRole
11+
metadata:
12+
name: {{ include "apl-harbor-operator.fullname" . }}-edit-harbor
13+
rules:
14+
# Allows the operator to read and watch configmaps. This is necessary to set up the harbor configuration.
15+
- apiGroups: [""]
16+
resources: ["configmaps"]
17+
verbs: ["get", "watch", "list"]
18+
# Allows the operator to CRUD secrets. This is necessary to set up the harbor robot accounts and team projects configuration.
19+
- apiGroups: [""]
20+
resources: ["secrets"]
21+
verbs: ["get", "watch", "list", "delete", "create", "update"]
22+
# Allows the operator to read service accounts. This is necessary to set up the harbor configuration.
23+
- apiGroups: [""]
24+
resources: ["serviceaccounts"]
25+
verbs: ["get", "list", "patch"]
26+
---
27+
apiVersion: rbac.authorization.k8s.io/v1
28+
kind: ClusterRoleBinding
29+
metadata:
30+
name: {{ include "apl-harbor-operator.fullname" . }}-edit-harbor
31+
subjects:
32+
- kind: ServiceAccount
33+
namespace: {{ .Release.Namespace }}
34+
name: {{ include "apl-harbor-operator.fullname" . }}
35+
roleRef:
36+
kind: ClusterRole
37+
name: {{ include "apl-harbor-operator.fullname" . }}-edit-harbor
38+
apiGroup: rbac.authorization.k8s.io
39+
{{- end }}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Default values for apl-harbor-operator.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image:
8+
repository: otomi/tasks
9+
pullPolicy: IfNotPresent
10+
# Overrides the image tag whose default is the chart appVersion.
11+
tag: main
12+
13+
imagePullSecrets: []
14+
nameOverride: ""
15+
fullnameOverride: ""
16+
17+
serviceAccount:
18+
# Specifies whether a service account should be created
19+
create: true
20+
name: "apl-harbor-operator"
21+
annotations: {}
22+
23+
podAnnotations: {}
24+
25+
podSecurityContext:
26+
runAsNonRoot: true
27+
runAsUser: 1001
28+
runAsGroup: 1001
29+
fsGroup: 2000
30+
31+
securityContext:
32+
capabilities:
33+
drop:
34+
- ALL
35+
readOnlyRootFilesystem: true
36+
runAsNonRoot: true
37+
runAsUser: 1001
38+
39+
resources: {}
40+
# We usually recommend not to specify default resources and to leave this as a conscious
41+
# choice for the user. This also increases chances charts run on environments with little
42+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
43+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
44+
# limits:
45+
# cpu: 100m
46+
# memory: 128Mi
47+
# requests:
48+
# cpu: 100m
49+
# memory: 128Mi
50+
51+
nodeSelector: {}
52+
53+
tolerations: []
54+
55+
affinity: {}
56+
57+
env: {}

core.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ k8s:
2323
disablePolicyChecks: true
2424
- name: harbor
2525
app: harbor
26+
- name: apl-harbor-operator
27+
disableIstioInjection: true
2628
- name: gitea
2729
- name: apl-gitea-operator
2830
disableIstioInjection: true

helmfile.d/helmfile-03.init.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ releases:
5252
labels:
5353
pkg: apl-gitea-operator
5454
<<: *default
55+
- name: apl-harbor-operator-artifacts
56+
installed: {{ $a | get "harbor.enabled" }}
57+
namespace: apl-harbor-operator
58+
labels:
59+
pkg: apl-harbor-operator
60+
<<: *raw
61+
- name: apl-harbor-operator
62+
installed: {{ $a | get "harbor.enabled" }}
63+
namespace: apl-harbor-operator
64+
labels:
65+
pkg: apl-harbor-operator
66+
<<: *default
5567
- name: kiali-operator-artifacts
5668
installed: {{ $a | get "kiali.enabled" }}
5769
namespace: kiali

helmfile.d/helmfile-99.post.yaml

-20
This file was deleted.

helmfile.d/snippets/defaults.yaml

+18-9
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,6 @@ environments:
181181
gitea:
182182
enabled: true
183183
adminUsername: otomi-admin
184-
apl-gitea-operator:
185-
resources:
186-
operator:
187-
requests:
188-
cpu: 100m
189-
memory: 128Mi
190-
limits:
191-
cpu: 200m
192-
memory: 256Mi
193184
grafana:
194185
enabled: false
195186
harbor:
@@ -457,6 +448,24 @@ environments:
457448
limits:
458449
cpu: 200m
459450
memory: 256Mi
451+
apl-harbor-operator:
452+
resources:
453+
operator:
454+
requests:
455+
cpu: 100m
456+
memory: 128Mi
457+
limits:
458+
cpu: 200m
459+
memory: 256Mi
460+
apl-gitea-operator:
461+
resources:
462+
operator:
463+
requests:
464+
cpu: 100m
465+
memory: 128Mi
466+
limits:
467+
cpu: 200m
468+
memory: 256Mi
460469
apl-keycloak-operator:
461470
resources:
462471
operator:

values-schema.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,16 @@ properties:
25382538
properties:
25392539
operator:
25402540
$ref: '#/definitions/resources'
2541+
apl-harbor-operator:
2542+
additionalProperties: false
2543+
properties:
2544+
_rawValues:
2545+
$ref: '#/definitions/rawValues'
2546+
resources:
2547+
additionalProperties: false
2548+
properties:
2549+
operator:
2550+
$ref: '#/definitions/resources'
25412551
apl-gitea-operator:
25422552
additionalProperties: false
25432553
properties:

0 commit comments

Comments
 (0)