Skip to content

Commit

Permalink
Merge pull request #281 from replicatedhq/1.11.1
Browse files Browse the repository at this point in the history
1.11.1 fixes
  • Loading branch information
laverya authored Jan 24, 2020
2 parents 1716f14 + 14fd692 commit 9238206
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ kubectl kots admin-console --namespace sentry-pro

# Community

For questions about using KOTS, there's a [Replicated Community](https://help.replicated.com/community) forum, and a [#kots channel in Kubernetes Slack](https://kubernetes.slack.com/channels/kots).
For questions about using KOTS, there's a [Replicated Community](https://help.replicated.com/community) forum, and a [#kots channel in Kubernetes Slack](https://kubernetes.slack.com/channels/kots).
26 changes: 26 additions & 0 deletions pkg/kotsadm/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,29 @@ func ensureAPIService(namespace string, clientset *kubernetes.Clientset) error {

return nil
}

func getAPIAutoCreateClusterToken(namespace string, clientset *kubernetes.Clientset) (string, error) {
existingDeployment, err := clientset.AppsV1().Deployments(namespace).Get("kotsadm-api", metav1.GetOptions{})
if err != nil {
return "", errors.Wrap(err, "failed to read deployment")
}

containerIdx := -1
for idx, c := range existingDeployment.Spec.Template.Spec.Containers {
if c.Name == "kotsadm-api" {
containerIdx = idx
}
}

if containerIdx == -1 {
return "", errors.New("failed to find kotsadm-api container in deployment")
}

for _, env := range existingDeployment.Spec.Template.Spec.Containers[containerIdx].Env {
if env.Name == "AUTO_CREATE_CLUSTER_TOKEN" {
return env.Value, nil
}
}

return "", errors.New("failed to find autocreateclustertoken env on api deployment")
}
9 changes: 9 additions & 0 deletions pkg/kotsadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,14 @@ func readDeployOptionsFromCluster(namespace string, kubeconfig string, clientset
}
}

// AutoCreateClusterToken
autocreateClusterToken, err := getAPIAutoCreateClusterToken(namespace, clientset)
if err != nil {
return nil, errors.Wrap(err, "failed to get auto create cluster token")
}
if autocreateClusterToken != "" {
deployOptions.AutoCreateClusterToken = autocreateClusterToken
}

return &deployOptions, nil
}
2 changes: 1 addition & 1 deletion pkg/kotsadm/operator_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func updateOperatorDeployment(deployment *appsv1.Deployment, deployOptions types
}
}

desiredDeployment := apiDeployment(deployOptions)
desiredDeployment := operatorDeployment(deployOptions)

// ensure the non-optional kots labels are present (added in 1.11.0)
if deployment.ObjectMeta.Labels == nil {
Expand Down

0 comments on commit 9238206

Please sign in to comment.