Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmackin committed Jun 23, 2020
1 parent f46e6a0 commit 64d93a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/vmo/sauronspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func InitializeSauronSpec(controller *Controller, sauron *vmcontrollerv1.Verrazz
glog.Errorf("Failed to create TLS Secrets for sauron: %v", err)
}

err = CopyTLSSecretToMonitoringNS(controller, sauron)
err = EnsureTlsSecretInMonitoringNS(controller, sauron)
if err != nil {
glog.Errorf("Failed to copy TLS Secret to monitoring namespace: %v", err)
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/vmo/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,22 @@ func (c *Controller) loadAllAuthSecretData(ns, secretName string) (map[string]st
// The prometheus pusher needs to access the ca.ctl cert in system-tls secret from within the pod. The secret must
// be in the monitoring namespace to access it as a volume. Copy the secret from the verrazzano-system
// namespace.
func CopyTLSSecretToMonitoringNS(controller *Controller, sauron *vmcontrollerv1.VerrazzanoMonitoringInstance) error {
func EnsureTlsSecretInMonitoringNS(controller *Controller, sauron *vmcontrollerv1.VerrazzanoMonitoringInstance) error {
const secretName = "system-tls"

// Don't copy the secret if it already exists.
secret, err := controller.kubeclientset.CoreV1().Secrets(constants.MonitoringNamespace).Get(secretName, metav1.GetOptions{})
if err == nil && secret != nil {
return nil
}

// The secret must be this name since the name is hardcoded in monitoring/deployments.do of verrazzano operator.
const secretName = "system-tls"
secret, err := controller.kubeclientset.CoreV1().Secrets(sauron.Namespace).Get(secretName, metav1.GetOptions{})
secret, err = controller.kubeclientset.CoreV1().Secrets(sauron.Namespace).Get(secretName, metav1.GetOptions{})
if err != nil {
glog.Errorf("Error getting TLS secret %s from namespace %s, err: %s", secretName, sauron.Namespace, err)
return err
}

// Always copy the secret even it is already exists, so try to delete it first.
controller.kubeclientset.CoreV1().Secrets(constants.MonitoringNamespace).Delete(secret.Name, &metav1.DeleteOptions{})

// Create the secret
newSecret := corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 64d93a2

Please sign in to comment.