Skip to content

Commit

Permalink
fix: pass SSH private key content as environment variable for K3s (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrummyFloyd authored Jul 4, 2024
1 parent a6e8d56 commit 06902d2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
1 change: 1 addition & 0 deletions extensions/k3s/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func readVaultTokenFromSecret(clientset *kubernetes.Clientset) string {
}

func GetK3sTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["TF_VAR_ssh_private_key"] = cl.K3sAuth.K3sSshPrivateKey
envs["AWS_ACCESS_KEY_ID"] = cl.StateStoreCredentials.AccessKeyID
envs["AWS_SECRET_ACCESS_KEY"] = cl.StateStoreCredentials.SecretAccessKey
envs["AWS_SESSION_TOKEN"] = "" // allows for debugging
Expand Down
2 changes: 0 additions & 2 deletions internal/controller/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func (clctrl *ClusterController) CreateCluster() error {
clctrl.Cluster.CloudTerraformApplyCheck = true
clctrl.Cluster.CloudTerraformApplyFailedCheck = false
err = secrets.UpdateCluster(clctrl.KubernetesClient, clctrl.Cluster)

if err != nil {
return err
}
Expand Down Expand Up @@ -264,7 +263,6 @@ func (clctrl *ClusterController) CreateTokens(kind string) interface{} {
gitopsTemplateTokens.K3sServersPrivateIps = clctrl.K3sAuth.K3sServersPrivateIps
gitopsTemplateTokens.K3sServersPublicIps = clctrl.K3sAuth.K3sServersPublicIps
gitopsTemplateTokens.SshUser = clctrl.K3sAuth.K3sSshUser
gitopsTemplateTokens.SshPrivateKey = clctrl.K3sAuth.K3sSshPrivateKey
gitopsTemplateTokens.K3sServersArgs = clctrl.K3sAuth.K3sServersArgs
}

Expand Down
1 change: 0 additions & 1 deletion pkg/providerConfigs/detokenize.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func detokenizeGitops(path string, tokens *GitopsDirectoryValues, gitProtocol st
newContents = strings.Replace(newContents, "<K3S_SERVERS_ARGS>", terraformServersArgsList, -1)

newContents = strings.Replace(newContents, "<SSH_USER>", tokens.SshUser, -1)
newContents = strings.Replace(newContents, "<SSH_PRIVATE_KEY_PATH>", tokens.SshPrivateKey, -1)
}
newContents = strings.Replace(newContents, "<ARGOCD_INGRESS_URL>", tokens.ArgoCDIngressURL, -1)
newContents = strings.Replace(newContents, "<ARGOCD_INGRESS_NO_HTTP_URL>", tokens.ArgoCDIngressNoHTTPSURL, -1)
Expand Down

0 comments on commit 06902d2

Please sign in to comment.