Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #70 from pacoxu/dev-0.0.5
Browse files Browse the repository at this point in the history
add kubelet-reloader support & support renew specified commands
  • Loading branch information
pacoxu authored Jun 14, 2022
2 parents 4357f8f + c1cbbc6 commit 52c0436
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 24 deletions.
10 changes: 1 addition & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
# distroless cannot run `kubeadm upgrade apply` smoothly
# FROM gcr.m.daocloud.io/distroless/static:nonroot
FROM docker.m.daocloud.io/ubuntu
RUN apt-get update -q -y && apt-get install -q -y curl systemd && apt clean all
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in ; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done);
RUN rm -rf /lib/systemd/system/multi-user.target.wants/;
RUN rm -rf /etc/systemd/system/.wants/;
RUN rm -rf /lib/systemd/system/local-fs.target.wants/;
RUN rm -rf /lib/systemd/system/sockets.target.wants/udev;
RUN rm -rf /lib/systemd/system/sockets.target.wants/initctl;
RUN rm -rf /lib/systemd/system/basic.target.wants/;
RUN rm -rf /lib/systemd/system/anaconda.target.wants/*;
RUN apt-get update -q -y && apt-get install -q -y curl && apt clean all

WORKDIR /
COPY --from=builder /workspace/manager .
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/operation_descriptor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ type UpgradeOperationSpec struct {

// RenewCertificatesOperationSpec provide declarative support for the kubeadm upgrade workflow.
type RenewCertificatesOperationSpec struct {
// +optional
// Commands is a list of commands to run: all, apiserver, apiserver-etcd-client, apiserver-kubelet-client,
// controller-manager.conf, etcd-healthcheck-client, etcd-peer, etcd-server, front-proxy-client, scheduler.conf
Commands []string `json:"commands"`

// INSERT ADDITIONAL SPEC FIELDS -
// Important: Run "make" to regenerate code after modifying this file
Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions commands/kubeadm_renew_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func runKubeadmRenewCertificates(spec *operatorv1.KubeadmRenewCertsCommandSpec,
spec.Commands = []string{"all"}
}

log.Info("Running kubeadm renew certificates command", "commands", spec.Commands)

for _, command := range spec.Commands {
cmd := newCmd("kubeadm", "certs", "renew", command)

Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/operator.kubeadm.x-k8s.io_operations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ spec:
renewCertificates:
description: RenewCertificates provide declarative support for the
kubeadm upgrade workflow.
properties:
commands:
description: 'Commands is a list of commands to run: all, apiserver,
apiserver-etcd-client, apiserver-kubelet-client, controller-manager.conf,
etcd-healthcheck-client, etcd-peer, etcd-server, front-proxy-client,
scheduler.conf'
items:
type: string
type: array
type: object
upgrade:
description: Upgrade provide declarative support for the kubeadm upgrade
Expand Down
26 changes: 13 additions & 13 deletions controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ func createDaemonSet(c client.Client, operation *operatorv1.Operation, namespace
Name: "kubeadm-binary",
MountPath: "/usr/bin/kubeadm",
},
{
Name: "kubelet-binary",
MountPath: "/usr/bin/kubelet",
},
// {
// Name: "kubelet-binary",
// MountPath: "/usr/bin/kubelet",
// },
{
Name: "kubelet-new-binary",
MountPath: "/usr/bin/kubelet-new",
Expand Down Expand Up @@ -228,15 +228,15 @@ func createDaemonSet(c client.Client, operation *operatorv1.Operation, namespace
},
},
},
{
Name: "kubelet-binary",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/usr/bin/kubelet",
Type: hostPathTypePtr(corev1.HostPathFile),
},
},
},
// {
// Name: "kubelet-binary",
// VolumeSource: corev1.VolumeSource{
// HostPath: &corev1.HostPathVolumeSource{
// Path: "/usr/bin/kubelet",
// Type: hostPathTypePtr(corev1.HostPathFile),
// },
// },
// },
{
Name: "kubelet-new-binary",
VolumeSource: corev1.VolumeSource{
Expand Down
4 changes: 3 additions & 1 deletion operations/renewcertificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ func planRenewCertificates(operation *operatorv1.Operation, spec *operatorv1.Ren
setCPSelector(&t1)
t1.Spec.Template.Spec.Commands = append(t1.Spec.Template.Spec.Commands,
operatorv1.CommandDescriptor{
KubeadmRenewCertificates: &operatorv1.KubeadmRenewCertsCommandSpec{},
KubeadmRenewCertificates: &operatorv1.KubeadmRenewCertsCommandSpec{
Commands: operation.Spec.RenewCertificates.Commands,
},
},
)
items = append(items, t1)
Expand Down
9 changes: 9 additions & 0 deletions samples/renew-apiserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: operator.kubeadm.x-k8s.io/v1alpha1
kind: Operation
metadata:
name: renew
spec:
executionMode: Auto
renewCertificates:
commands:
- apiserver
9 changes: 9 additions & 0 deletions samples/upgrade-v1.24.1-auto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: operator.kubeadm.x-k8s.io/v1alpha1
kind: Operation
metadata:
name: upgrade-v1.24.1
spec:
executionMode: Auto
upgrade:
kubernetesVersion: v1.24.1
local: false

0 comments on commit 52c0436

Please sign in to comment.