Skip to content

Commit 35e9670

Browse files
authored
Merge pull request #7 from planetscale/joem/k8s-yaml-examples
docs: add ./examples dir with k8s manifests
2 parents 8b51c9d + 07ecca0 commit 35e9670

File tree

7 files changed

+196
-0
lines changed

7 files changed

+196
-0
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths-ignore:
77
- README.md
88
- doc/**
9+
- examples/**
910
- .github/**
1011
- renovate.json5
1112
workflow_dispatch:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A Kubernetes controller that watches Kubernetes Nodes and copies labels from the node to the cloud provider's VM as tags (AWS) or labels (GCP).
44

5+
## Deployment
6+
7+
See the [./examples](./examples) directory for example manifests. These are just examples, please read them carefully and adjust if needed.
8+
59
## Testing
610

711
- lint: `make lint`

examples/ciliumnetworkpolicy.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: cilium.io/v2
2+
kind: CiliumNetworkPolicy
3+
metadata:
4+
name: k8s-node-tagger
5+
specs:
6+
- description: Allow access to AWS STS API
7+
endpointSelector:
8+
matchLabels:
9+
app: k8s-node-tagger
10+
egress:
11+
- toFQDNs:
12+
- matchName: sts.amazonaws.com
13+
- matchPattern: sts.*.amazonaws.com
14+
toPorts:
15+
- ports:
16+
- port: "443"
17+
protocol: TCP
18+
19+
- description: Allow access to AWS EC2 API
20+
endpointSelector:
21+
matchLabels:
22+
app: k8s-node-tagger
23+
egress:
24+
- toFQDNs:
25+
- matchName: ec2.amazonaws.com
26+
- matchPattern: ec2.*.amazonaws.com
27+
toPorts:
28+
- ports:
29+
- port: "443"
30+
protocol: TCP
31+
32+
- description: Allow access to GCP GCE instance metadata service
33+
endpointSelector:
34+
matchLabels:
35+
app: k8s-node-tagger
36+
egress:
37+
- toCIDR:
38+
- 169.254.169.254/32
39+
toPorts:
40+
- ports:
41+
- port: "80"
42+
protocol: TCP
43+
44+
- description: Allow access to GCP GCE API
45+
endpointSelector:
46+
matchLabels:
47+
app: k8s-node-tagger
48+
egress:
49+
- toFQDNs:
50+
- matchName: compute.googleapis.com
51+
toPorts:
52+
- ports:
53+
- port: "443"
54+
protocol: TCP

examples/deployment.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: k8s-node-tagger
5+
spec:
6+
# NOTE: we could do replicas: 2 here. If so, add the '-enable-leader-election' flag
7+
replicas: 1
8+
9+
selector:
10+
matchLabels:
11+
app: k8s-node-tagger
12+
template:
13+
metadata:
14+
labels:
15+
app: k8s-node-tagger
16+
spec:
17+
serviceAccountName: k8s-node-tagger
18+
containers:
19+
- name: k8s-node-tagger
20+
image: ghcr.io/planetscale/k8s-node-tagger:v0.0.15@sha256:7e5074b10cc113afaf6ea17465ad8de2b9b08acf24cc55e98f4eb5aafe4e1982
21+
imagePullPolicy: IfNotPresent
22+
args:
23+
- -cloud=aws
24+
# - -cloud=gcp
25+
- -labels=database-branch-id,psdb.co/shard,psdb.co/cluster,psdb.co/keyspace,psdb.co/component,psdb.co/size
26+
- -json
27+
ports:
28+
- name: http
29+
containerPort: 8080
30+
protocol: TCP
31+
- name: metrics
32+
containerPort: 8081
33+
protocol: TCP
34+
livenessProbe:
35+
httpGet:
36+
path: /healthz
37+
port: http
38+
readinessProbe:
39+
httpGet:
40+
path: /healthz
41+
port: http
42+
resources:
43+
requests:
44+
memory: 64Mi

examples/rbac.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: k8s-node-tagger
5+
6+
# clusterrole for k8s-node-tagger to read/watch nodes
7+
---
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: ClusterRole
10+
metadata:
11+
name: k8s-node-tagger
12+
rules:
13+
- apiGroups:
14+
- ""
15+
resources:
16+
- nodes
17+
verbs:
18+
- get
19+
- list
20+
- watch
21+
---
22+
kind: ClusterRoleBinding
23+
apiVersion: rbac.authorization.k8s.io/v1
24+
metadata:
25+
name: k8s-node-tagger
26+
subjects:
27+
- kind: ServiceAccount
28+
name: k8s-node-tagger
29+
namespace: k8s-node-tagger
30+
roleRef:
31+
kind: ClusterRole
32+
name: k8s-node-tagger
33+
apiGroup: rbac.authorization.k8s.io
34+
35+
# namespace role for k8s-node-tagger to use the lease API. Shouldn't be needed if leader election is disabled.
36+
---
37+
apiVersion: rbac.authorization.k8s.io/v1
38+
kind: Role
39+
metadata:
40+
name: k8s-node-tagger
41+
rules:
42+
- apiGroups:
43+
- coordination.k8s.io
44+
resources:
45+
- leases
46+
verbs:
47+
- create
48+
- get
49+
- update
50+
---
51+
kind: RoleBinding
52+
apiVersion: rbac.authorization.k8s.io/v1
53+
metadata:
54+
name: k8s-node-tagger
55+
subjects:
56+
- kind: ServiceAccount
57+
name: k8s-node-tagger
58+
namespace: k8s-node-tagger
59+
roleRef:
60+
kind: Role
61+
name: k8s-node-tagger
62+
apiGroup: rbac.authorization.k8s.io

examples/service.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: k8s-node-tagger
5+
labels:
6+
app: k8s-node-tagger
7+
spec:
8+
type: ClusterIP
9+
ports:
10+
- name: http
11+
port: 8080
12+
targetPort: http
13+
- name: metrics
14+
port: 8081
15+
targetPort: metrics
16+
selector:
17+
app: k8s-node-tagger

examples/servicemonitor.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
name: k8s-node-tagger
5+
spec:
6+
endpoints:
7+
- port: metrics
8+
jobLabel: jobLabel
9+
namespaceSelector:
10+
matchNames:
11+
- k8s-node-tagger
12+
selector:
13+
matchLabels:
14+
app: k8s-node-tagger

0 commit comments

Comments
 (0)