From eb2360418396b10179d2f4f9bc12752289627c77 Mon Sep 17 00:00:00 2001 From: Soohyun Kim Date: Tue, 9 Jun 2020 15:02:51 +0200 Subject: [PATCH] METAL-1890 trigger pod restart on proxysql config changes --- pkg/utils/proxy/proxysql.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/utils/proxy/proxysql.go b/pkg/utils/proxy/proxysql.go index 59ea5eb0..0dd2406c 100644 --- a/pkg/utils/proxy/proxysql.go +++ b/pkg/utils/proxy/proxysql.go @@ -6,6 +6,7 @@ import ( "strconv" "text/template" + "github.com/kloeckner-i/db-operator/pkg/utils/kci" proxysql "github.com/kloeckner-i/db-operator/pkg/utils/proxy/proxysql" v1apps "k8s.io/api/apps/v1" @@ -23,6 +24,7 @@ type ProxySQL struct { MonitorUserSecretName string Engine string Labels map[string]string + configCheckSum string } const sqlPort = 6033 @@ -140,6 +142,9 @@ func (ps *ProxySQL) deploymentSpec() (v1apps.DeploymentSpec, error) { }, } + annotations := make(map[string]string) + annotations["checksum/config"] = ps.configCheckSum + return v1apps.DeploymentSpec{ Replicas: &replicas, Selector: &metav1.LabelSelector{ @@ -147,7 +152,8 @@ func (ps *ProxySQL) deploymentSpec() (v1apps.DeploymentSpec, error) { }, Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: ps.Labels, + Labels: ps.Labels, + Annotations: annotations, }, Spec: v1.PodSpec{ InitContainers: []v1.Container{configGenContainer}, @@ -265,6 +271,8 @@ func (ps *ProxySQL) buildConfigMap() (*v1.ConfigMap, error) { "proxysql.cnf.tmpl": outputBuf.String(), } + ps.configCheckSum = kci.GenerateChecksum(data) + return &v1.ConfigMap{ TypeMeta: metav1.TypeMeta{ Kind: "ConfigMap",