Skip to content

Commit

Permalink
chore: support helmify to generate charts (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: shilinlee <[email protected]>
  • Loading branch information
shilinlee authored Sep 17, 2023
1 parent 3e0b59f commit 79c2861
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ bin/
.vscode
.idea
.fleet
.DS_Store
10 changes: 10 additions & 0 deletions Makefile.kube
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,13 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

HELMIFY ?= $(LOCALBIN)/helmify

.PHONY: helmify
helmify: $(HELMIFY) ## Download helmify locally if necessary.
$(HELMIFY): $(LOCALBIN)
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest

helm: manifests kustomize helmify
$(KUSTOMIZE) build config/default | $(HELMIFY) charts
10 changes: 5 additions & 5 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chart.fullname" . }}-controller-manager
name: {{ include "charts.fullname" . }}-controller-manager
labels:
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
control-plane: controller-manager
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.controllerManager.replicas }}
selector:
matchLabels:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 6 }}
{{- include "charts.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 8 }}
{{- include "charts.selectorLabels" . | nindent 8 }}
annotations:
kubectl.kubernetes.io/default-container: manager
spec:
Expand Down Expand Up @@ -94,5 +94,5 @@ spec:
- ALL
securityContext:
runAsNonRoot: true
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
serviceAccountName: {{ include "charts.fullname" . }}-controller-manager
terminationGracePeriodSeconds: 10
20 changes: 16 additions & 4 deletions charts/templates/geminicluster-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
spec:
group: opengemini-operator.opengemini.org
names:
Expand Down Expand Up @@ -45,7 +45,11 @@ spec:
required:
- enablePodAntiAffinity
type: object
enableSuperuserAccess:
customAdminSecretName:
type: string
customConfigMapName:
type: string
enableHttpAuth:
default: false
type: boolean
meta:
Expand Down Expand Up @@ -557,8 +561,6 @@ spec:
- dataVolumeClaimSpec
- image
type: object
superuserSecret:
type: string
version:
type: string
required:
Expand All @@ -572,6 +574,13 @@ spec:
status:
description: GeminiClusterStatus defines the observed state of GeminiCluster
properties:
adminUserInitialized:
default: false
description: if admin user has initialized
type: boolean
appliedConfigHash:
description: md5 hash of applied config file content
type: string
conditions:
description: conditions represent the observations of cluster's current
state.
Expand Down Expand Up @@ -680,6 +689,9 @@ spec:
type: integer
statusDetails:
type: string
required:
- adminUserInitialized
- appliedConfigHash
type: object
type: object
served: true
Expand Down
12 changes: 6 additions & 6 deletions charts/templates/leader-election-rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "chart.fullname" . }}-leader-election-role
name: {{ include "charts.fullname" . }}-leader-election-role
labels:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -43,17 +43,17 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "chart.fullname" . }}-leader-election-rolebinding
name: {{ include "charts.fullname" . }}-leader-election-rolebinding
labels:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: '{{ include "chart.fullname" . }}-leader-election-role'
name: '{{ include "charts.fullname" . }}-leader-election-role'
subjects:
- kind: ServiceAccount
name: '{{ include "chart.fullname" . }}-controller-manager'
name: '{{ include "charts.fullname" . }}-controller-manager'
namespace: '{{ .Release.Namespace }}'
22 changes: 9 additions & 13 deletions charts/templates/manager-rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chart.fullname" . }}-manager-role
name: {{ include "charts.fullname" . }}-manager-role
labels:
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand All @@ -13,6 +13,7 @@ rules:
- create
- get
- list
- patch
- watch
- apiGroups:
- ""
Expand All @@ -24,17 +25,13 @@ rules:
- list
- patch
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- list
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- delete
- get
- list
- watch
Expand All @@ -44,7 +41,6 @@ rules:
- services
verbs:
- create
- delete
- get
- list
- watch
Expand Down Expand Up @@ -98,17 +94,17 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "chart.fullname" . }}-manager-rolebinding
name: {{ include "charts.fullname" . }}-manager-rolebinding
labels:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: '{{ include "chart.fullname" . }}-manager-role'
name: '{{ include "charts.fullname" . }}-manager-role'
subjects:
- kind: ServiceAccount
name: '{{ include "chart.fullname" . }}-controller-manager'
name: '{{ include "charts.fullname" . }}-controller-manager'
namespace: '{{ .Release.Namespace }}'
4 changes: 2 additions & 2 deletions charts/templates/metrics-reader-rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chart.fullname" . }}-metrics-reader
name: {{ include "charts.fullname" . }}-metrics-reader
labels:
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
rules:
- nonResourceURLs:
- /metrics
Expand Down
6 changes: 3 additions & 3 deletions charts/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "chart.fullname" . }}-controller-manager-metrics-service
name: {{ include "charts.fullname" . }}-controller-manager-metrics-service
labels:
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
control-plane: controller-manager
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
spec:
type: ClusterIP
selector:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 4 }}
{{- include "charts.selectorLabels" . | nindent 4 }}
ports:
- name: https
port: 8443
Expand Down
12 changes: 6 additions & 6 deletions charts/templates/proxy-rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chart.fullname" . }}-proxy-role
name: {{ include "charts.fullname" . }}-proxy-role
labels:
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
rules:
- apiGroups:
- authentication.k8s.io
Expand All @@ -24,17 +24,17 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "chart.fullname" . }}-proxy-rolebinding
name: {{ include "charts.fullname" . }}-proxy-rolebinding
labels:
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: '{{ include "chart.fullname" . }}-proxy-role'
name: '{{ include "charts.fullname" . }}-proxy-role'
subjects:
- kind: ServiceAccount
name: '{{ include "chart.fullname" . }}-controller-manager'
name: '{{ include "charts.fullname" . }}-controller-manager'
namespace: '{{ .Release.Namespace }}'
4 changes: 2 additions & 2 deletions charts/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "chart.fullname" . }}-controller-manager
name: {{ include "charts.fullname" . }}-controller-manager
labels:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: opengemini-operator
app.kubernetes.io/part-of: opengemini-operator
{{- include "chart.labels" . | nindent 4 }}
{{- include "charts.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.controllerManager.serviceAccount.annotations | nindent 4 }}
4 changes: 2 additions & 2 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ controllerManager:
memory: 64Mi
manager:
image:
repository: ghcr.io/opengemini/opengemini-operator:latest
tag: 814de3b
repository: ghcr.io/opengemini/opengemini-operator
tag: latest
resources:
limits:
cpu: 500m
Expand Down
8 changes: 4 additions & 4 deletions config/samples/opengemini-operator_v1_geminicluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ spec:
resources:
requests:
storage: 1Gi
image: opengeminidb/opengemini-k8s:v1.0.1
image: opengeminidb/opengemini-k8s:v1.1.0-rc1
replicas: 3
resources:
requests:
cpu: 100m
memory: 512Mi
sql:
image: opengeminidb/opengemini-k8s:v1.0.1
image: opengeminidb/opengemini-k8s:v1.1.0-rc1
port: "8086"
replicas: 2
replicas: 3
resources:
requests:
cpu: 100m
Expand All @@ -39,7 +39,7 @@ spec:
resources:
requests:
storage: 1Gi
image: opengeminidb/opengemini-k8s:v1.0.1
image: opengeminidb/opengemini-k8s:v1.1.0-rc1
replicas: 3
resources:
requests:
Expand Down

0 comments on commit 79c2861

Please sign in to comment.