Skip to content

Commit

Permalink
fix(cmd/scripts/kubernetes/create_cluster_admin): Use "kubectl create…
Browse files Browse the repository at this point in the history
… token" instead manually creating secret with token
  • Loading branch information
ondrejsika committed Dec 12, 2023
1 parent 276e9a3 commit a882a87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ var Cmd = &cobra.Command{
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
suffix := strconv.Itoa(int(time.Now().Unix()))
k8s_scripts.CreateClusterAdmin(suffix, FlagDry)
token := getTokenOrDie("kube-system", "cluster-admin-"+suffix)
fmt.Println("cluster-admin-" + suffix)
fmt.Println(token)
k8s_scripts.CreateClusterAdmin(suffix, FlagDry)
},
}

Expand Down
12 changes: 2 additions & 10 deletions utils/k8s_scripts/k8s_scripts_create_cluster_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ metadata:
name: cluster-admin-`+suffix+`
namespace: kube-system
secrets:
- name: cluster-admin-`+suffix+`
---
apiVersion: v1
kind: Secret
metadata:
name: cluster-admin-`+suffix+`
namespace: kube-system
annotations:
kubernetes.io/service-account.name: cluster-admin-`+suffix+`
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -32,4 +22,6 @@ subjects:
name: cluster-admin-`+suffix+`
namespace: kube-system
EOF`, dry)

sh(`kubectl create token -n kube-system cluster-admin-`+suffix+` --duration 999999h`, dry)
}

0 comments on commit a882a87

Please sign in to comment.