Skip to content

Commit

Permalink
Merge pull request #26 from kloeckner-i/METAL-1890/proxysql_check_con…
Browse files Browse the repository at this point in the history
…fig_changes

METAL-1890 trigger pod restart on proxysql config changes
  • Loading branch information
hyunysmile authored Jun 9, 2020
2 parents f5a04a8 + eb23604 commit 36e204d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/utils/proxy/proxysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,6 +24,7 @@ type ProxySQL struct {
MonitorUserSecretName string
Engine string
Labels map[string]string
configCheckSum string
}

const sqlPort = 6033
Expand Down Expand Up @@ -140,14 +142,18 @@ 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{
MatchLabels: ps.Labels,
},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: ps.Labels,
Labels: ps.Labels,
Annotations: annotations,
},
Spec: v1.PodSpec{
InitContainers: []v1.Container{configGenContainer},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 36e204d

Please sign in to comment.