fix: remove double labels, make upgrade_cluster work reliably on clustered control plane

This commit is contained in:
Stefan Reimer 2024-07-26 13:46:58 +00:00
parent 22c43c7089
commit 3ba48840b5
2 changed files with 14 additions and 11 deletions

View File

@ -148,10 +148,8 @@ kubeadm_upgrade() {
post_kubeadm post_kubeadm
# If we have a re-cert kubectl config install for root # install re-certed kubectl config for root
if [ -f ${HOSTFS}/etc/kubernetes/super-admin.conf ]; then cp ${HOSTFS}/etc/kubernetes/super-admin.conf ${HOSTFS}/root/.kube/config
cp ${HOSTFS}/etc/kubernetes/super-admin.conf ${HOSTFS}/root/.kube/config
fi
# post upgrade hook # post upgrade hook
[ -f /var/lib/kubezero/post-upgrade.sh ] && . /var/lib/kubezero/post-upgrade.sh [ -f /var/lib/kubezero/post-upgrade.sh ] && . /var/lib/kubezero/post-upgrade.sh
@ -260,7 +258,12 @@ control_plane_node() {
_kubeadm init phase kubelet-start _kubeadm init phase kubelet-start
cp ${HOSTFS}/etc/kubernetes/super-admin.conf ${HOSTFS}/root/.kube/config # Remove conditional with 1.30
if [ -f ${HOSTFS}/etc/kubernetes/super-admin.conf ]; then
cp ${HOSTFS}/etc/kubernetes/super-admin.conf ${HOSTFS}/root/.kube/config
else
cp ${HOSTFS}/etc/kubernetes/admin.conf ${HOSTFS}/root/.kube/config
fi
# Wait for api to be online # Wait for api to be online
echo "Waiting for Kubernetes API to be online ..." echo "Waiting for Kubernetes API to be online ..."
@ -306,7 +309,7 @@ control_plane_node() {
post_kubeadm post_kubeadm
echo "${1} cluster $CLUSTERNAME successfull." echo "${CMD}ed cluster $CLUSTERNAME successfully."
} }
@ -364,7 +367,9 @@ backup() {
# pki & cluster-admin access # pki & cluster-admin access
cp -r ${HOSTFS}/etc/kubernetes/pki ${WORKDIR} cp -r ${HOSTFS}/etc/kubernetes/pki ${WORKDIR}
cp ${HOSTFS}/etc/kubernetes/admin.conf ${WORKDIR} cp ${HOSTFS}/etc/kubernetes/admin.conf ${WORKDIR}
cp ${HOSTFS}/etc/kubernetes/super-admin.conf ${WORKDIR}
# Remove conditional with 1.30
[ -f ${HOSTFS}/etc/kubernetes/super-admin.conf ] && cp ${HOSTFS}/etc/kubernetes/super-admin.conf ${WORKDIR}
# Backup via restic # Backup via restic
restic backup ${WORKDIR} -H $CLUSTERNAME --tag $CLUSTER_VERSION restic backup ${WORKDIR} -H $CLUSTERNAME --tag $CLUSTER_VERSION

View File

@ -6,10 +6,9 @@ metadata:
labels: labels:
common.k8s.elastic.co/type: elasticsearch common.k8s.elastic.co/type: elasticsearch
elasticsearch.k8s.elastic.co/cluster-name: {{ template "kubezero-lib.fullname" $ }} elasticsearch.k8s.elastic.co/cluster-name: {{ template "kubezero-lib.fullname" $ }}
{{ include "kubezero-lib.labels" . | nindent 4 }}
name: {{ template "kubezero-lib.fullname" $ }}-es-elastic-user name: {{ template "kubezero-lib.fullname" $ }}-es-elastic-user
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
data: data:
elastic: {{ .Values.elastic_password | b64enc | quote }} elastic: {{ .Values.elastic_password | b64enc | quote }}
--- ---
@ -20,10 +19,9 @@ metadata:
labels: labels:
common.k8s.elastic.co/type: elasticsearch common.k8s.elastic.co/type: elasticsearch
elasticsearch.k8s.elastic.co/cluster-name: {{ template "kubezero-lib.fullname" $ }} elasticsearch.k8s.elastic.co/cluster-name: {{ template "kubezero-lib.fullname" $ }}
{{ include "kubezero-lib.labels" . | nindent 4 }}
name: {{ template "kubezero-lib.fullname" $ }}-es-elastic-username name: {{ template "kubezero-lib.fullname" $ }}-es-elastic-username
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
data: data:
username: {{ "elastic" | b64enc | quote }} username: {{ "elastic" | b64enc | quote }}
{{- end }} {{- end }}