Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit af80ee7

Browse files
authored
Merge pull request #67 from jetstack/sa-output
Add command to get a new cluster service account
2 parents b2dc875 + 94cab1e commit af80ee7

23 files changed

+464
-229
lines changed

docs/reference/jsctl_auth.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Subcommands for authentication
2020
### SEE ALSO
2121

2222
* [jsctl](jsctl.md) - Command-line tool for the Jetstack Secure Control Plane
23+
* [jsctl auth clusters](jsctl_auth_clusters.md) -
2324
* [jsctl auth login](jsctl_auth_login.md) - Performs the authentication flow to allow access to other commands
2425
* [jsctl auth logout](jsctl_auth_logout.md) -
2526
* [jsctl auth status](jsctl_auth_status.md) - Print the logged in account and token location
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## jsctl auth clusters
2+
3+
4+
5+
### Options
6+
7+
```
8+
-h, --help help for clusters
9+
```
10+
11+
### Options inherited from parent commands
12+
13+
```
14+
--api-url string Base URL of the control-plane API (default "https://platform.jetstack.io")
15+
--config string Location of the user's jsctl config directory (default "HOME or USERPROFILE/.jsctl")
16+
--kubeconfig string Location of the user's kubeconfig file for applying directly to the cluster (default "~/.kube/config")
17+
--stdout If provided, manifests are written to stdout rather than applied to the current cluster
18+
```
19+
20+
### SEE ALSO
21+
22+
* [jsctl auth](jsctl_auth.md) - Subcommands for authentication
23+
* [jsctl auth clusters create-service-account](jsctl_auth_clusters_create-service-account.md) - Create a new Jetstack Secure service account for a cluster agent
24+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## jsctl auth clusters create-service-account
2+
3+
Create a new Jetstack Secure service account for a cluster agent
4+
5+
### Synopsis
6+
7+
Generate a new service account for a Jetstack Secure cluster agent
8+
This is only needed if you are not deploying the agent with jsctl.
9+
Output can be json formatted or as Kubernetes Secret.
10+
11+
12+
```
13+
jsctl auth clusters create-service-account name [flags]
14+
```
15+
16+
### Options
17+
18+
```
19+
--format string The desired output format, valid options: [jsonKeyData, secret] (default "jsonKeyData")
20+
-h, --help help for create-service-account
21+
--secret-name string If using the 'secret' format, the name of the secret to create (default "agent-credentials")
22+
--secret-namespace string If using the 'secret' format, the namespace of the secret to create (default "jetstack-secure")
23+
```
24+
25+
### Options inherited from parent commands
26+
27+
```
28+
--api-url string Base URL of the control-plane API (default "https://platform.jetstack.io")
29+
--config string Location of the user's jsctl config directory (default "HOME or USERPROFILE/.jsctl")
30+
--kubeconfig string Location of the user's kubeconfig file for applying directly to the cluster (default "~/.kube/config")
31+
--stdout If provided, manifests are written to stdout rather than applied to the current cluster
32+
```
33+
34+
### SEE ALSO
35+
36+
* [jsctl auth clusters](jsctl_auth_clusters.md) -
37+

docs/reference/jsctl_clusters_connect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Creates a new cluster in the control plane and deploys the agent in your current kubenetes context
44

55
```
6-
jsctl clusters connect [name] [flags]
6+
jsctl clusters connect name [flags]
77
```
88

99
### Options

docs/reference/jsctl_clusters_delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Deletes a cluster from the organization
44

55
```
6-
jsctl clusters delete [name] [flags]
6+
jsctl clusters delete name [flags]
77
```
88

99
### Options

docs/reference/jsctl_clusters_view.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Opens a browser window to the cluster's dashboard
44

55
```
6-
jsctl clusters view [name] [flags]
6+
jsctl clusters view name [flags]
77
```
88

99
### Options

docs/reference/jsctl_configuration_set_organization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Set your current organization
44

55
```
6-
jsctl configuration set organization [value] [flags]
6+
jsctl configuration set organization name [flags]
77
```
88

99
### Options

docs/reference/jsctl_users_add.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Add a user to the current organization
44

55
```
6-
jsctl users add [email] [flags]
6+
jsctl users add email [flags]
77
```
88

99
### Options

docs/reference/jsctl_users_remove.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Remove a user from the current organization
44

55
```
6-
jsctl users remove [email] [flags]
6+
jsctl users remove email [flags]
77
```
88

99
### Options

internal/cluster/cluster.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import (
1515
"text/template"
1616
"time"
1717

18+
corev1 "k8s.io/api/core/v1"
19+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20+
1821
"github.com/jetstack/jsctl/internal/client"
1922
)
2023

@@ -158,3 +161,24 @@ func marshalBase64(in interface{}) ([]byte, error) {
158161

159162
return buffer.Bytes(), nil
160163
}
164+
165+
// AgentServiceAccount secret takes a service account json and formats it as a
166+
// k8s secret.
167+
func AgentServiceAccountSecret(keyData []byte, name, namespace string) *corev1.Secret {
168+
secret := &corev1.Secret{
169+
TypeMeta: metav1.TypeMeta{
170+
APIVersion: corev1.SchemeGroupVersion.String(),
171+
Kind: "Secret",
172+
},
173+
ObjectMeta: metav1.ObjectMeta{
174+
Name: name,
175+
Namespace: namespace,
176+
},
177+
Type: corev1.SecretTypeOpaque,
178+
Data: map[string][]byte{
179+
"credentials.json": keyData,
180+
},
181+
}
182+
183+
return secret
184+
}

0 commit comments

Comments
 (0)