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

support upgrade crd #395

Merged
merged 1 commit into from
Nov 12, 2023
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
16 changes: 16 additions & 0 deletions Dockerfile.multiarch
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
FROM alpine:3.18.2

ARG TARGETPLATFORM
ARG TARGETARCH

RUN addgroup -S -g 65532 ng-user && \
adduser -S -D -H -u 65532 \
-s /sbin/nologin -G ng-user -g ng-user ng-user

RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
curl \
&& rm -rf /var/cache/apk/*

RUN mkdir -p /tmp/nebula-operator
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin

ADD charts/nebula-operator/crds/nebulaautoscalers.yaml /tmp/nebula-operator/nebulaautoscalers.yaml
ADD charts/nebula-operator/crds/nebulaclusters.yaml /tmp/nebula-operator/nebulaclusters.yaml
ADD charts/nebula-operator/crds/nebularestores.yaml /tmp/nebula-operator/nebularestores.yaml

ADD bin/${TARGETPLATFORM}/controller-manager /usr/local/bin/controller-manager
ADD bin/${TARGETPLATFORM}/autoscaler /usr/local/bin/autoscaler
ADD bin/${TARGETPLATFORM}/scheduler /usr/local/bin/scheduler
Expand Down
11 changes: 11 additions & 0 deletions charts/nebula-operator/templates/controller-manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ rules:
- get
- list
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- list
- watch
- update
- patch
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
36 changes: 36 additions & 0 deletions charts/nebula-operator/templates/upgrade_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.upgradeCRD }}
apiVersion: batch/v1
kind: Job
metadata:
name: nebula-operator-upgrade-crd
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
labels:
{{- include "nebula-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: "nebula-operator"
spec:
template:
metadata:
name: nebula-operator-upgrade-crd
labels:
{{- include "nebula-operator.labels" . | nindent 8 }}
app.kubernetes.io/component: "nebula-operator"
spec:
serviceAccountName: {{ template "controller-manager.name" . }}-sa
{{- include "nebula-operator.imagePullSecrets" . | indent 6 }}
containers:
- name: upgrade-crd
image: {{ .Values.image.nebulaOperator.image }}
imagePullPolicy: {{ .Values.image.nebulaOperator.imagePullPolicy }}
command:
- /bin/sh
- -c
- >
kubectl apply -f /tmp/nebula-operator/nebulaautoscalers.yaml;
kubectl apply -f /tmp/nebula-operator/nebulaclusters.yaml;
kubectl apply -f /tmp/nebula-operator/nebularestores.yaml;
restartPolicy: OnFailure
{{- end }}
3 changes: 3 additions & 0 deletions charts/nebula-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ scheduler:
enabled: ["NodeZone"]
disabled: [] # only in-tree plugins need to be defined here

# upgrade CRD on chart upgrade
upgradeCRD: true

# Enable openkruise scheme for controller manager. (default false)
enableKruiseScheme: false

Expand Down