Add version label to the cluster. (#96)
* Add version label to the cluster. According to the STUPS team the daemon that exports logs to scalyr stops the export if the version label is missing. * Move label names to constants. * Run go fmt
This commit is contained in:
parent
08c0e3b6dd
commit
47e3e29a56
|
|
@ -156,10 +156,10 @@ func (c *Cluster) waitPodLabelsReady() error {
|
||||||
LabelSelector: ls.String(),
|
LabelSelector: ls.String(),
|
||||||
}
|
}
|
||||||
masterListOption := v1.ListOptions{
|
masterListOption := v1.ListOptions{
|
||||||
LabelSelector: labels.Merge(ls, labels.Set{"spilo-role": constants.PodRoleMaster}).String(),
|
LabelSelector: labels.Merge(ls, labels.Set{constants.SpiloRoleLabel: constants.PodRoleMaster}).String(),
|
||||||
}
|
}
|
||||||
replicaListOption := v1.ListOptions{
|
replicaListOption := v1.ListOptions{
|
||||||
LabelSelector: labels.Merge(ls, labels.Set{"spilo-role": constants.PodRoleReplica}).String(),
|
LabelSelector: labels.Merge(ls, labels.Set{constants.SpiloRoleLabel: constants.PodRoleReplica}).String(),
|
||||||
}
|
}
|
||||||
pods, err := c.KubeClient.Pods(namespace).List(listOptions)
|
pods, err := c.KubeClient.Pods(namespace).List(listOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -204,8 +204,8 @@ func (c *Cluster) waitStatefulsetPodsReady() error {
|
||||||
|
|
||||||
func (c *Cluster) labelsSet() labels.Set {
|
func (c *Cluster) labelsSet() labels.Set {
|
||||||
return labels.Set{
|
return labels.Set{
|
||||||
"application": "spilo",
|
constants.ApplicationNameLabel: constants.ApplicationNameLabelValue,
|
||||||
"spilo-cluster": c.Metadata.Name,
|
constants.ClusterNameLabel: c.Metadata.Name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ func clusterName(clusterName string, teamName string) (string, error) {
|
||||||
if len(clusterName) < teamNameLen+2 {
|
if len(clusterName) < teamNameLen+2 {
|
||||||
return "", fmt.Errorf("Name is too short")
|
return "", fmt.Errorf("Name is too short")
|
||||||
}
|
}
|
||||||
if strings.ToLower(clusterName[:teamNameLen+1]) != strings.ToLower(teamName) + "-" {
|
if strings.ToLower(clusterName[:teamNameLen+1]) != strings.ToLower(teamName)+"-" {
|
||||||
return "", fmt.Errorf("Name must start with the team name and dash")
|
return "", fmt.Errorf("Name must start with the team name and dash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,8 @@ const (
|
||||||
ResourceName = TPRName + "s"
|
ResourceName = TPRName + "s"
|
||||||
PodRoleMaster = "master"
|
PodRoleMaster = "master"
|
||||||
PodRoleReplica = "replica"
|
PodRoleReplica = "replica"
|
||||||
|
ApplicationNameLabel = "application"
|
||||||
|
ApplicationNameLabelValue = "spilo"
|
||||||
|
SpiloRoleLabel = "spilo-role"
|
||||||
|
ClusterNameLabel = "version"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,14 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/motomux/pretty"
|
"github.com/motomux/pretty"
|
||||||
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
|
|
||||||
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
|
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"github.bus.zalan.do/acid/postgres-operator/pkg/util/constants"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var passwordChars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
var passwordChars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||||
|
|
@ -37,7 +38,7 @@ func NameFromMeta(meta v1.ObjectMeta) spec.NamespacedName {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PodClusterName(pod *v1.Pod) spec.NamespacedName {
|
func PodClusterName(pod *v1.Pod) spec.NamespacedName {
|
||||||
if name, ok := pod.Labels["spilo-cluster"]; ok {
|
if name, ok := pod.Labels[constants.ClusterNameLabel]; ok {
|
||||||
return spec.NamespacedName{
|
return spec.NamespacedName{
|
||||||
Namespace: pod.Namespace,
|
Namespace: pod.Namespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
@ -48,7 +49,7 @@ func PodClusterName(pod *v1.Pod) spec.NamespacedName {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PodSpiloRole(pod *v1.Pod) string {
|
func PodSpiloRole(pod *v1.Pod) string {
|
||||||
return pod.Labels["spilo-role"]
|
return pod.Labels[constants.SpiloRoleLabel]
|
||||||
}
|
}
|
||||||
|
|
||||||
func PGUserPassword(user spec.PgUser) string {
|
func PGUserPassword(user spec.PgUser) string {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue