Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 585b281

Browse files
authored
Merge pull request #18 from arista-netdevops-community/k8s-file
howto: add k8s example
2 parents e1cb1c9 + 6bc2167 commit 585b281

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ Use following `devcontainer.json` to start:
111111
Unfortunately `devcontainer.json` is not yet supported with VScode Remote-SSH plugin. You can track recent development [here](https://github.com/microsoft/vscode-remote-release/issues/2994).
112112
The easiest way to use avd-all-in-one container with remote SSH is creating a simple alias: `alias avd="sudo docker run --rm -it -v $(pwd):/home/avd/projects/ avdteam/avd-all-in-one"`
113113

114+
115+
### run avd-all-in-one in k8s
116+
117+
[k8s-avd-cvp.yml](k8s-avd-cvp.yml) is an example pod definition for running avd-all-in-one on CloudVision (CentOS), however
118+
it should work on other linux distributions (the CVP env vars won't be needed in that case).
119+
120+
The below example is for running the pod on one specific node (set by the `nodeName: $PRIMARY_HOSTNAME` node selection in the spec)
121+
122+
1. Download the docker image: `docker pull avdteam/avd-all-in-one`
123+
2. Create avd group and user: `groupadd -g 1000 avd && useradd avd -u 1000 -g 1000`
124+
3. Create projects in `/home/avd`
125+
4. Deploy the k8s pod: `envsubst < /cvpi/conf/kubernetes/avd.yml | kubectl apply -f -`
126+
127+
> Note that the pod can be also deployed on any node by removing the `nodeName` field from the spec, however that would also require
128+
> pulling the image onto all nodes and synchronozing the project files between all nodes.
129+
114130
## Known Caveats
115131

116132
### Curly Brackets May Not Work as Expected

k8s-avd-cvp.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: avd
5+
labels:
6+
app: avd
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: avd
12+
template:
13+
metadata:
14+
labels:
15+
app: avd
16+
spec:
17+
node: $PRIMARY_HOSTNAME
18+
hostNetwork: false
19+
securityContext:
20+
runAsUser: 1000
21+
dnsPolicy: ClusterFirst
22+
containers:
23+
- name: avd
24+
image: avdteam/avd-all-in-one:latest
25+
imagePullPolicy: Never
26+
securityContext:
27+
allowPrivilegeEscalation: true
28+
capabilities:
29+
drop:
30+
- all
31+
readOnlyRootFilesystem: false
32+
env:
33+
- name: CVP_MODE
34+
value: $CVP_MODE
35+
- name: CVP_VERSION
36+
value: $CVP_VERSION
37+
- name: PRIMARY_DEVICE_INTF_IP
38+
value: $PRIMARY_DEVICE_INTF_IP
39+
- name: SECONDARY_DEVICE_INTF_IP
40+
value: $SECONDARY_DEVICE_INTF_IP
41+
- name: TERTIARY_DEVICE_INTF_IP
42+
value: $TERTIARY_DEVICE_INTF_IP
43+
- name: PRIMARY_HOST_IP
44+
value: $PRIMARY_HOST_IP
45+
- name: SECONDARY_HOST_IP
46+
value: $SECONDARY_HOST_IP
47+
- name: TERTIARY_HOST_IP
48+
value: $TERTIARY_HOST_IP
49+
- name: PRIMARY_HOSTNAME
50+
value: $PRIMARY_HOSTNAME
51+
- name: SECONDARY_HOSTNAME
52+
value: $SECONDARY_HOSTNAME
53+
- name: TERTIARY_HOSTNAME
54+
value: $TERTIARY_HOSTNAME
55+
- name: AERIS_INGEST_KEY
56+
value: '$AERIS_INGEST_KEY'
57+
- name: CURRENT_NODE_IP
58+
valueFrom:
59+
fieldRef:
60+
fieldPath: status.hostIP
61+
command:
62+
- zsh
63+
- -c
64+
- --
65+
args:
66+
- while true;
67+
- do sleep 3000;
68+
- done;
69+
volumeMounts:
70+
- name: tmpfs
71+
mountPath: /tmp
72+
- name: certs-dir
73+
mountPath: /usr/share/nginx/images
74+
readOnly: true
75+
- name: lib64
76+
mountPath: /usr/lib64
77+
readOnly: true
78+
- name: home-avd
79+
mountPath: /projects
80+
readOnly: false
81+
resources:
82+
limits:
83+
cpu: "3"
84+
memory: "4Gi"
85+
requests:
86+
cpu: "100m"
87+
memory: "100Mi"
88+
terminationGracePeriodSeconds: 10
89+
volumes:
90+
- name: tmpfs
91+
hostPath:
92+
path: /tmp
93+
- name: certs-dir
94+
hostPath:
95+
path: /usr/share/nginx/certs
96+
- name: lib64
97+
hostPath:
98+
path: /usr/lib64
99+
- name: home-avd
100+
hostPath:
101+
path: /home/avd

0 commit comments

Comments
 (0)