You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/kubernetes-multi-service/README.md
+72Lines changed: 72 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,75 @@ name: Develop multiple services in Kubernetes
3
3
description: Get started with Kubernetes development.
4
4
tags: [cloud, kubernetes]
5
5
---
6
+
7
+
# Authentication
8
+
9
+
This template has several ways to authenticate to a Kubernetes cluster.
10
+
11
+
## kubeconfig (Coder host)
12
+
13
+
If the Coder host has a local `~/.kube/config`, this can be used to authenticate with Coder. Make sure this is on the same user running the `coder` service.
14
+
15
+
## ServiceAccount
16
+
17
+
Create a ServiceAccount and role on your cluster to authenticate your template with Coder.
18
+
19
+
1. Run the following command on a device with Kubernetes context:
20
+
21
+
```sh
22
+
CODER_NAMESPACE=default
23
+
kubectl apply -n $CODER_NAMESPACE -f - <<EOF
24
+
apiVersion: v1
25
+
kind: ServiceAccount
26
+
metadata:
27
+
name: coder
28
+
---
29
+
apiVersion: rbac.authorization.k8s.io/v1
30
+
kind: Role
31
+
metadata:
32
+
name: coder
33
+
rules:
34
+
- apiGroups: ["", "apps", "networking.k8s.io"] # "" indicates the core API group
Copy file name to clipboardExpand all lines: examples/kubernetes-multi-service/main.tf
+55-1Lines changed: 55 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,62 @@ terraform {
11
11
}
12
12
}
13
13
14
+
variable"step1_use_kubeconfig" {
15
+
type=bool
16
+
sensitive=true
17
+
description="Use local ~/.kube/config? (true/false)"
18
+
}
19
+
20
+
variable"step2_cluster_host" {
21
+
type=string
22
+
sensitive=true
23
+
description=<<-EOF
24
+
Hint: You can use:
25
+
$ kubectl cluster-info | grep "control plane"
26
+
27
+
28
+
Leave blank if using ~/.kube/config (from step 1)
29
+
EOF
30
+
}
31
+
32
+
variable"step3_certificate" {
33
+
type=string
34
+
sensitive=true
35
+
description=<<-EOF
36
+
Use docs at https://github.com/coder/coder/tree/main/examples/kubernetes-multi-service#serviceaccount to create a ServiceAccount for Coder and grab values.
37
+
38
+
Enter CA certificate
39
+
40
+
Leave blank if using ~/.kube/config (from step 1)
41
+
EOF
42
+
}
43
+
44
+
variable"step4_token" {
45
+
type=string
46
+
sensitive=true
47
+
description=<<-EOF
48
+
Enter token (refer to docs at https://github.com/coder/coder/tree/main/examples/kubernetes-multi-service#serviceaccount)
49
+
50
+
Leave blank if using ~/.kube/config (from step 1)
51
+
EOF
52
+
}
53
+
54
+
variable"step5_coder_namespace" {
55
+
type=string
56
+
sensitive=true
57
+
description=<<-EOF
58
+
Enter namespace (refer to docs at https://github.com/coder/coder/tree/main/examples/kubernetes-multi-service#serviceaccount)
59
+
60
+
Leave blank if using ~/.kube/config (from step 1)
61
+
EOF
62
+
}
63
+
14
64
provider"kubernetes" {
15
-
config_path="~/.kube/config"
65
+
# Authenticate via ~/.kube/config or a Coder-specific ServiceAccount, depending on admin preferences
0 commit comments