Use ConfigMap to store operator's config

This commit is contained in:
Murat Kabilov
2017-05-12 11:41:34 +02:00
parent 47e3e29a56
commit da438aab3a
16 changed files with 323 additions and 147 deletions
+1 -1
View File
@@ -183,7 +183,7 @@ func (c *Cluster) recreatePods() error {
var masterPod v1.Pod
for _, pod := range pods.Items {
role := util.PodSpiloRole(&pod)
role := c.PodSpiloRole(&pod)
if role == constants.PodRoleMaster {
masterPod = pod
+16 -8
View File
@@ -103,7 +103,7 @@ func (c *Cluster) waitForPodLabel(podEvents chan spec.PodEvent) error {
for {
select {
case podEvent := <-podEvents:
role := util.PodSpiloRole(podEvent.CurPod)
role := c.PodSpiloRole(podEvent.CurPod)
// We cannot assume any role of the newly created pod. Normally, for a multi-pod cluster
// we should observe the 'replica' value, but it could be that some pods are not allowed
// to promote, therefore, the new pod could be a master as well.
@@ -156,10 +156,14 @@ func (c *Cluster) waitPodLabelsReady() error {
LabelSelector: ls.String(),
}
masterListOption := v1.ListOptions{
LabelSelector: labels.Merge(ls, labels.Set{constants.SpiloRoleLabel: constants.PodRoleMaster}).String(),
LabelSelector: labels.Merge(ls, labels.Set{
c.OpConfig.PodRoleLabel: constants.PodRoleMaster,
}).String(),
}
replicaListOption := v1.ListOptions{
LabelSelector: labels.Merge(ls, labels.Set{constants.SpiloRoleLabel: constants.PodRoleReplica}).String(),
LabelSelector: labels.Merge(ls, labels.Set{
c.OpConfig.PodRoleLabel: constants.PodRoleReplica,
}).String(),
}
pods, err := c.KubeClient.Pods(namespace).List(listOptions)
if err != nil {
@@ -203,10 +207,10 @@ func (c *Cluster) waitStatefulsetPodsReady() error {
}
func (c *Cluster) labelsSet() labels.Set {
return labels.Set{
constants.ApplicationNameLabel: constants.ApplicationNameLabelValue,
constants.ClusterNameLabel: c.Metadata.Name,
}
lbls := c.OpConfig.ClusterLabels
lbls[c.OpConfig.ClusterNameLabel] = c.Metadata.Name
return labels.Set(lbls)
}
func (c *Cluster) dnsName() string {
@@ -228,7 +232,7 @@ func (c *Cluster) credentialSecretName(username string) string {
}
func (c *Cluster) deleteEtcdKey() error {
etcdKey := fmt.Sprintf("/service/%s", c.Metadata.Name)
etcdKey := fmt.Sprintf("/%s/%s", c.OpConfig.EtcdScope, c.Metadata.Name)
//TODO: retry multiple times
resp, err := c.EtcdClient.Delete(context.Background(),
@@ -245,3 +249,7 @@ func (c *Cluster) deleteEtcdKey() error {
return nil
}
func (c *Cluster) PodSpiloRole(pod *v1.Pod) string {
return pod.Labels[c.OpConfig.PodRoleLabel]
}