forked from contiv/vpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpp.yaml
executable file
·1675 lines (1621 loc) · 58.6 KB
/
vpp.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Contiv-VPP deployment YAML file. This deploys Contiv VPP networking on a Kuberntes cluster.
# The deployment consists of the following components:
# - contiv-etcd - deployed on k8s master
# - contiv-vswitch - deployed on each k8s node
# - contiv-ksr - deployed on k8s master
{{- if contains ":" .Values.contiv.ipamConfig.podSubnetCIDR }}
{{- $ignored := set . "any_addr_tmp" "[::]" }}
{{- $ignored := set . "localhost_addr_tmp" "[::1]" }}
{{- else }}
{{- $ignored := set . "any_addr_tmp" "0.0.0.0" }}
{{- $ignored := set . "localhost_addr_tmp" "127.0.0.1" }}
{{- end }}
{{- $any_addr := .any_addr_tmp -}}
{{- $localhost_addr := .localhost_addr_tmp }}
###########################################################
# Configuration
###########################################################
# This config map contains contiv-agent configuration. The most important part is the ipamConfig,
# which may be updated in case the default IPAM settings do not match your needs.
# nodeConfig may be used in case your nodes have more than 1 VPP interface. In that case, one
# of them needs to be marked as the main inter-node interface, and the rest of them can be
# configured with any IP addresses (the IPs cannot conflict with the main IPAM config).
apiVersion: v1
kind: ConfigMap
metadata:
name: contiv-agent-cfg
namespace: kube-system
data:
contiv.conf: |-
nodeToNodeTransport: {{ .Values.contiv.nodeToNodeTransport }}
useSRv6ForServices: {{ .Values.contiv.useSRv6ForServices }}
useTAPInterfaces: {{ .Values.contiv.useTAPInterfaces }}
tapInterfaceVersion: {{ .Values.contiv.tapInterfaceVersion }}
{{- if eq (.Values.contiv.tapInterfaceVersion | int) 2 }}
tapv2RxRingSize: {{ .Values.contiv.tapv2RxRingSize }}
tapv2TxRingSize: {{ .Values.contiv.tapv2TxRingSize }}
enableGSO: {{ .Values.contiv.enableGSO }}
{{- end }}
{{- if ne (.Values.contiv.vmxnet3RxRingSize | int) 1024 }}
vmxnet3RxRingSize: {{ .Values.contiv.vmxnet3RxRingSize }}
{{- end }}
{{- if ne (.Values.contiv.vmxnet3TxRingSize | int) 1024 }}
vmxnet3TxRingSize: {{ .Values.contiv.vmxnet3TxRingSize }}
{{- end }}
{{- if ne .Values.contiv.interfaceRxMode "default" }}
interfaceRxMode: {{ .Values.contiv.interfaceRxMode }}
{{- end }}
tcpChecksumOffloadDisabled: true
{{- if .Values.contiv.stealInterface }}
stealInterface: {{ .Values.contiv.stealInterface }}
{{- end }}
{{- if .Values.contiv.stealFirstNIC }}
stealFirstNIC: True
{{- end }}
STNVersion: {{ .Values.contiv.stnVersion }}
natExternalTraffic: {{ .Values.contiv.natExternalTraffic }}
mtuSize: {{ .Values.contiv.mtuSize }}
scanIPNeighbors: {{ .Values.contiv.scanIPNeighbors }}
ipNeighborScanInterval: {{ .Values.contiv.ipNeighborScanInterval }}
ipNeighborStaleThreshold: {{ .Values.contiv.ipNeighborStaleThreshold }}
enablePacketTrace: {{ .Values.contiv.enablePacketTrace }}
routeServiceCIDRToVPP: {{ .Values.contiv.routeServiceCIDRToVPP }}
crdNodeConfigurationDisabled: {{ .Values.contiv.crdNodeConfigurationDisabled }}
ipamConfig:
{{- if .Values.contiv.ipamConfig.useExternalIPAM }}
useExternalIPAM: true
{{- end }}
{{- if .Values.contiv.ipamConfig.contivCIDR }}
contivCIDR: {{ .Values.contiv.ipamConfig.contivCIDR }}
{{- else }}
nodeInterconnectDHCP: {{ .Values.contiv.ipamConfig.nodeInterconnectDHCP }}
{{- if .Values.contiv.ipamConfig.nodeInterconnectCIDR }}
nodeInterconnectCIDR: {{ .Values.contiv.ipamConfig.nodeInterconnectCIDR }}
{{- end }}
{{- if .Values.contiv.ipamConfig.defaultGateway }}
defaultGateway: {{ .Values.contiv.ipamConfig.defaultGateway }}
{{- end }}
podSubnetCIDR: {{ .Values.contiv.ipamConfig.podSubnetCIDR }}
podSubnetOneNodePrefixLen: {{ .Values.contiv.ipamConfig.podSubnetOneNodePrefixLen }}
vppHostSubnetCIDR: {{ .Values.contiv.ipamConfig.vppHostSubnetCIDR }}
vppHostSubnetOneNodePrefixLen: {{ .Values.contiv.ipamConfig.vppHostSubnetOneNodePrefixLen }}
vxlanCIDR: {{ .Values.contiv.ipamConfig.vxlanCIDR }}
{{- end }}
{{- if .Values.contiv.ipamConfig.serviceCIDR }}
serviceCIDR: {{ .Values.contiv.ipamConfig.serviceCIDR }}
{{- end }}
srv6:
servicePolicyBSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.servicePolicyBSIDSubnetCIDR }}
servicePodLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.servicePodLocalSIDSubnetCIDR }}
serviceHostLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.serviceHostLocalSIDSubnetCIDR }}
serviceNodeLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.serviceNodeLocalSIDSubnetCIDR }}
nodeToNodePodLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodePodLocalSIDSubnetCIDR }}
nodeToNodeHostLocalSIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodeHostLocalSIDSubnetCIDR }}
nodeToNodePodPolicySIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodePodPolicySIDSubnetCIDR }}
nodeToNodeHostPolicySIDSubnetCIDR: {{ .Values.contiv.ipamConfig.srv6.nodeToNodeHostPolicySIDSubnetCIDR }}
{{- if .Values.contiv.nodeConfig }}
nodeConfig:
{{- range .Values.contiv.nodeConfig }}
- nodeName: {{ .name }}
mainVPPInterface:
interfaceName: {{ .mainInterface.interfaceName }}
{{- if .mainInterface.useDHCP }}
useDHCP: {{ .mainInterface.useDHCP }}
{{- end -}}
{{- if .mainInterface.ip }}
ip: {{ .mainInterface.ip }}
{{- end -}}
{{- if .natExternalTraffic }}
natExternalTraffic: {{ .natExternalTraffic }}
{{- end }}
{{- if .gateway }}
gateway: {{ .gateway }}
{{- end -}}
{{- if .stealInterface }}
stealInterface: {{ .stealInterface }}
{{- end -}}
{{- if .otherInterfaces }}
otherVPPInterfaces:
{{- range $iface := .otherInterfaces }}
- interfaceName: {{ $iface.interfaceName }}
ip: {{ $iface.ip }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
controller.conf: |
enableRetry: {{ .Values.controller.enableRetry }}
delayRetry: {{ .Values.controller.delayRetry | int64 }}
maxRetryAttempts: {{ .Values.controller.maxRetryAttempts }}
enableExpBackoffRetry: {{ .Values.controller.enableExpBackoffRetry }}
delayLocalResync: {{ .Values.controller.delayLocalResync | int64 }}
startupResyncDeadline: {{ .Values.controller.startupResyncDeadline | int64 }}
enablePeriodicHealing: {{ .Values.controller.enablePeriodicHealing }}
periodicHealingInterval: {{ .Values.controller.periodicHealingInterval | int64 }}
delayAfterErrorHealing: {{ .Values.controller.delayAfterErrorHealing | int64 }}
remoteDBProbingInterval: {{ .Values.controller.remoteDBProbingInterval | int64 }}
recordEventHistory: {{ .Values.controller.recordEventHistory }}
eventHistoryAgeLimit: {{ .Values.controller.eventHistoryAgeLimit }}
permanentlyRecordedInitPeriod: {{ .Values.controller.permanentlyRecordedInitPeriod }}
service.conf: |
{{- if .Values.contiv.cleanupIdleNATSessions }}
cleanupIdleNATSessions: true
tcpNATSessionTimeout: {{ .Values.contiv.tcpNATSessionTimeout }}
otherNATSessionTimeout: {{ .Values.contiv.otherNATSessionTimeout }}
{{- end }}
{{- if .Values.contiv.serviceLocalEndpointWeight }}
serviceLocalEndpointWeight: {{ .Values.contiv.serviceLocalEndpointWeight }}
{{- end }}
disableNATVirtualReassembly: {{ .Values.contiv.disableNATVirtualReassembly }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: vpp-agent-cfg
namespace: kube-system
data:
govpp.conf: |
health-check-probe-interval: {{ .Values.govpp.healthCheckProbeInterval | int64 }}
health-check-reply-timeout: {{ .Values.govpp.healthCheckReplyTimeout | int64 }}
health-check-threshold: {{ .Values.govpp.healthCheckThreshold | int64 }}
reply-timeout: {{ .Values.govpp.replyTimeout | int64 }}
logs.conf: |
default-level: {{ .Values.logs.defaultLevel }}
loggers:
- name: statscollector
level: info
- name: vpp.if-state
level: info
- name: linux.arp-conf
level: info
- name: vpp-rest
level: info
grpc.conf: |
network: unix
endpoint: /var/run/contiv/cni.sock
force-socket-removal: true
permission: 700
http.conf: |
endpoint: "{{ $any_addr }}:9999"
{{- if .Values.http.enableServerCert }}
server-cert-file: /var/http/{{ .Values.http.serverCert }}
server-key-file: /var/http/{{ .Values.http.serverKey }}
{{- end }}
{{- if .Values.http.enableBasicAuth }}
client-basic-auth:
- {{ .Values.http.basicAuth | quote }}
{{- end }}
bolt.conf: |
db-path: /var/bolt/bolt.db
file-mode: 432
lock-timeout: 0
telemetry.conf: |
polling-interval: {{ .Values.telemetry.pollingInterval | int64 }}
disabled: {{ .Values.telemetry.disabled }}
linux-ifplugin.conf: |
dump-go-routines-count: 5
linux-l3plugin.conf: |
dump-go-routines-count: 5
kvscheduler.conf: |
record-transaction-history: {{ .Values.controller.recordEventHistory }}
transaction-history-age-limit: {{ .Values.controller.eventHistoryAgeLimit }}
permanently-recorded-init-period: {{ .Values.controller.permanentlyRecordedInitPeriod }}
---
kind: ConfigMap
apiVersion: v1
metadata:
name: contiv-cni-cfg
namespace: kube-system
data:
# The CNI network configuration to install on each node. The special
# values in this config will be automatically populated.
10-contiv-vpp.conflist: |-
{
"name": "k8s-pod-network",
"cniVersion": "0.3.1",
"plugins": [
{
"type": "contiv-cni",
"grpcServer": "/var/run/contiv/cni.sock",
{{- if .Values.contiv.ipamConfig.useExternalIPAM }}
"ipam": {
"type": "host-local",
"subnet": "usePodCidr"
},
"etcdEndpoints" : "{{ $localhost_addr }}:{{ .Values.etcd.service.nodePort }}",
{{- end }}
"logFile": "/var/run/contiv/cni.log"
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
},
"externalSetMarkChain": "KUBE-MARK-MASQ"
}
]
}
---
###########################################################
#
# !!! DO NOT EDIT THINGS BELOW THIS LINE !!!
#
###########################################################
###########################################################
# Components and other resources
###########################################################
# This installs the contiv-etcd (ETCD server to be used by Contiv) on the master node in a Kubernetes cluster.
# In odrer to dump the content of ETCD, you can use the kubectl exec command similar to this:
# kubectl exec contiv-etcd-cxqhr -n kube-system etcdctl -- get --endpoints=[127.0.0.1:12379] --prefix="true" ""
{{- define "utils.commaseparated" -}}
{{- $local := dict "first" true -}}
{{- range $k, $v := . -}}{{- if not $local.first -}},{{- end -}}{{- $v -}}{{- $_ := set $local "first" false -}}{{- end -}}
{{- end }}
{{- if not .Values.etcd.useExternalInstance }}
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: contiv-etcd
namespace: kube-system
labels:
k8s-app: contiv-etcd
spec:
serviceName: contiv-etcd
selector:
matchLabels:
k8s-app: contiv-etcd
updateStrategy:
type: {{ .Values.etcd.updateStrategy }}
template:
metadata:
labels:
k8s-app: contiv-etcd
annotations:
# Marks this pod as a critical add-on.
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
tolerations:
# We need this to schedule on the master no matter what else is going on, so tolerate everything.
- key: ''
operator: Exists
effect: ''
# This likely isn't needed due to the above wildcard, but keep it in for now.
- key: CriticalAddonsOnly
operator: Exists
# Only run this pod on the master.
nodeSelector:
node-role.kubernetes.io/master: ""
hostNetwork: true
containers:
- name: contiv-etcd
{{- if .Values.Arm64Platform }}
image: {{ .Values.etcd_arm64.image.repository }}:{{ .Values.etcd_arm64.image.tag }}
{{- else }}
image: {{ .Values.etcd.image.repository }}:{{ .Values.etcd.image.tag }}
{{- end }}
imagePullPolicy: {{ .Values.etcd.image.pullPolicy }}
env:
- name: CONTIV_ETCD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: HOST_IP
{{- if .Values.etcd.service.useNodeIP }}
valueFrom:
fieldRef:
fieldPath: status.hostIP
{{- else }}
value: "127.0.0.1"
{{- end }}
- name: ETCDCTL_API
value: "3"
{{- if .Values.Arm64Platform }}
- name: ETCD_UNSUPPORTED_ARCH
value: "arm64"
{{- end }}
{{- if .Values.etcd.secureTransport }}
- name: ETCDCTL_CACERT
value: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.caCert }}
- name: ETCDCTL_CERT
value: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientCert }}
- name: ETCDCTL_KEY
value: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientKey }}
{{- end }}
command:
- /bin/sh
args:
- -c
- /usr/local/bin/etcd --name=contiv-etcd --data-dir=/var/etcd/contiv-data
{{- if .Values.etcd.secureTransport }}
--client-cert-auth --trusted-ca-file=/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.caCert }}
--cert-file=/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.serverCert }} --key-file=/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.serverKey }}
--peer-client-cert-auth --peer-trusted-ca-file=/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.caCert }}
--peer-cert-file=/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.serverCert }} --peer-key-file=/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.serverKey }}
--advertise-client-urls=https://{{ $any_addr }}:12379 --listen-client-urls=https://{{ $any_addr }}:12379 --listen-peer-urls=https://{{ $any_addr }}:12380
{{- if .Values.etcd.cipherSuites }}
--cipher-suites {{ include "utils.commaseparated" .Values.etcd.cipherSuites }}
{{- end }}
{{- else }}
--advertise-client-urls=http://{{ $any_addr }}:12379 --listen-client-urls=http://{{ $any_addr }}:12379 --listen-peer-urls=http://{{ $any_addr }}:12380
{{- end }}
volumeMounts:
- name: var-etcd
mountPath: /var/etcd/
{{- if .Values.etcd.secureTransport }}
- name: etcd-secrets
mountPath: /var/contiv/etcd-secrets
readOnly: true
{{- end }}
{{- if .Values.etcd.enableLivenessProbe }}
livenessProbe:
exec:
command:
- /bin/sh
- -c
- |
echo "$HOST_IP" | grep -q ':'
if [ "$?" -eq "0" ];
then
HOST_IP="[$HOST_IP]"
fi
etcdctl get --endpoints=$HOST_IP:{{ .Values.etcd.service.nodePort }} /
periodSeconds: {{ .Values.etcd.probePeriodSeconds }}
initialDelaySeconds: {{ .Values.etcd.livenessProbeInitialDelaySeconds }}
{{- end }}
resources:
{{- if .Values.etcd.cpuLimit }}
limits:
cpu: {{ .Values.etcd.cpuLimit }}
{{- end }}
{{- if .Values.etcd.cpuRequest }}
requests:
cpu: {{ .Values.etcd.cpuRequest }}
{{- end }}
{{- if .Values.etcd.secureTransport }}
volumes:
- name: etcd-secrets
{{- if .Values.etcd.secrets.mountFromHost }}
hostPath:
path: {{ .Values.etcd.secrets.mountDir }}
{{- else }}
secret:
secretName: contiv-etcd-secrets
items:
- key: caCert
path: {{ .Values.etcd.secrets.caCert }}
- key: serverCert
path: {{ .Values.etcd.secrets.serverCert }}
- key: serverKey
path: {{ .Values.etcd.secrets.serverKey }}
- key: clientCert
path: {{ .Values.etcd.secrets.clientCert }}
- key: clientKey
path: {{ .Values.etcd.secrets.clientKey }}
{{- end }}
{{- end }}
{{- if .Values.etcd.usePersistentVolume }}
volumeClaimTemplates:
- metadata:
name: var-etcd
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.etcd.persistentVolumeSize }}
{{- if .Values.etcd.persistentVolumeStorageClass }}
{{- if (eq "-" .Values.etcd.persistentVolumeStorageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.etcd.persistentVolumeStorageClass }}"
{{- end }}
{{- end }}
{{- else }}
{{- if not .Values.etcd.secureTransport }}
volumes:
{{- end }}
- name: var-etcd
hostPath:
path: {{ .Values.etcd.dataDir }}
{{- end }}
{{- if .Values.etcd.secureTransport }}
{{- if not .Values.etcd.secrets.mountFromHost }}
---
# The following contains k8s Secrets for use with a TLS enabled etcd cluster.
# For information on populating Secrets, see http://kubernetes.io/docs/user-guide/secrets/
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: contiv-etcd-secrets
namespace: kube-system
data:
caCert: |-
{{ .Files.Get .Values.etcd.secrets.caCert | b64enc }}
serverCert: |-
{{ .Files.Get .Values.etcd.secrets.serverCert | b64enc }}
serverKey: |-
{{ .Files.Get .Values.etcd.secrets.serverKey | b64enc }}
clientCert: |-
{{ .Files.Get .Values.etcd.secrets.clientCert | b64enc }}
clientKey: |-
{{ .Files.Get .Values.etcd.secrets.clientKey | b64enc }}
{{- end }}
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
name: contiv-etcd
namespace: kube-system
spec:
type: NodePort
# Match contiv-etcd DaemonSet.
selector:
k8s-app: contiv-etcd
ports:
- port: 12379
nodePort: {{ .Values.etcd.service.nodePort }}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: contiv-ksr-http-cfg
namespace: kube-system
data:
http.conf: |
endpoint: "{{ $any_addr }}:9191"
{{- if .Values.http.enableServerCert }}
server-cert-file: /var/http/{{ .Values.http.serverCert }}
server-key-file: /var/http/{{ .Values.http.serverKey }}
{{- end }}
{{- if .Values.http.enableBasicAuth }}
client-basic-auth:
- {{ .Values.http.basicAuth | quote }}
{{- end }}
---
# This config map contains ETCD configuration for connecting to the contiv-etcd defined above.
apiVersion: v1
kind: ConfigMap
metadata:
name: contiv-etcd-cfg
namespace: kube-system
data:
etcd.conf: |
dial-timeout: 10000000000
allow-delayed-start: true
{{- if .Values.etcd.useExternalInstance }}
{{- if .Values.etcd.externalInstance.secretName }}
insecure-transport: false
ca-file: /var/contiv/etcd-secrets/caCert
cert-file: /var/contiv/etcd-secrets/clientCert
key-file: /var/contiv/etcd-secrets/clientKey
{{- else }}
insecure-transport: true
{{- end }}
endpoints:
{{- range .Values.etcd.externalInstance.endpoints }}
- {{ . | quote }}
{{- end }}
{{- else }}
{{- if .Values.etcd.secureTransport }}
insecure-transport: false
ca-file: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.caCert }}
cert-file: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientCert }}
key-file: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientKey }}
{{- else }}
insecure-transport: true
{{- end }}
endpoints:
{{- if .Values.etcd.service.useNodeIP }}
- "__HOST_IP__:{{ .Values.etcd.service.nodePort }}"
{{- else }}
- "127.0.0.1:{{ .Values.etcd.service.nodePort }}"
{{- end }}
{{- end }}
---
{{- if not .Values.etcd.useExternalInstance }}
# This config map contains ETCD configuration for connecting to the contiv-etcd defined above with auto compact.
apiVersion: v1
kind: ConfigMap
metadata:
name: contiv-etcd-withcompact-cfg
namespace: kube-system
data:
etcd.conf: |
{{- if .Values.etcd.secureTransport }}
insecure-transport: false
ca-file: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.caCert }}
cert-file: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientCert }}
key-file: /var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientKey }}
{{- else }}
insecure-transport: true
{{- end }}
dial-timeout: 10000000000
auto-compact: 600000000000
allow-delayed-start: true
reconnect-interval: 2000000000
endpoints:
{{- if .Values.etcd.service.useNodeIP }}
- "__HOST_IP__:{{ .Values.etcd.service.nodePort }}"
{{- else }}
- "127.0.0.1:{{ .Values.etcd.service.nodePort }}"
{{- end }}
{{- if .Values.http.enableServerCert }}
{{- if not .Values.http.mountFromHost }}
---
{{- end }} # end of if useExternalETCDinstance
# The following contains k8s Secrets for use with a secured HTTP plugin.
# For information on populating Secrets, see http://kubernetes.io/docs/user-guide/secrets/
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: contiv-http-secrets
namespace: kube-system
data:
serverCert: |-
{{ .Files.Get .Values.http.serverCert | b64enc }}
serverKey: |-
{{ .Files.Get .Values.http.serverKey | b64enc }}
{{- end }}
{{- end }}
---
# This installs contiv-vswitch on each master and worker node in a Kubernetes cluster.
# It consists of the following containers:
# - contiv-vswitch container: contains VPP and its management agent
# - contiv-cni container: installs CNI on the host
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: contiv-vswitch
namespace: kube-system
labels:
k8s-app: contiv-vswitch
spec:
selector:
matchLabels:
k8s-app: contiv-vswitch
updateStrategy:
type: {{ .Values.vswitch.updateStrategy }}
template:
metadata:
labels:
k8s-app: contiv-vswitch
annotations:
# Marks this pod as a critical add-on.
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
{{- if .Values.vswitch.useNodeAffinity }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: cni-type
operator: In
values:
- vpp
{{- end }}
tolerations:
# We need this to schedule on the master no matter what else is going on, so tolerate everything.
- key: ''
operator: Exists
effect: ''
# This likely isn't needed due to the above wildcard, but keep it in for now.
- key: CriticalAddonsOnly
operator: Exists
hostNetwork: true
hostPID: true
# Init containers are executed before regular containers, must finish successfully before regular ones are started.
initContainers:
# This container installs the Contiv CNI binaries and CNI network config file on each node.
- name: contiv-cni
{{- if .Values.Arm64Platform }}
image: {{ .Values.cni_arm64.image.repository }}:{{ default .Chart.Version .Values.cni.image.tag }}
{{- else }}
image: {{ .Values.cni.image.repository }}:{{ default .Chart.Version .Values.cni.image.tag }}
{{- end }}
imagePullPolicy: IfNotPresent
env:
- name: SLEEP
value: "false"
volumeMounts:
- mountPath: /opt/cni/bin
name: cni-bin-dir
- mountPath: /etc/cni/net.d
name: cni-net-dir
- mountPath: /cni/cfg
name: contiv-cni-cfg
- mountPath: /var/run/contiv
name: contiv-run
{{- if eq .Values.contiv.crdNodeConfigurationDisabled false }}
# This init container waits until crd node specific configuration has been applied
- name: wait-forcrdconfig
env:
- name: ETCDCTL_API
value: "3"
- name: ETCDCTL_ENDPOINTS
{{- if .Values.etcd.useExternalInstance }}
value: {{ include "utils.commaseparated" .Values.etcd.externalInstance.endpoints | quote }}
{{- end }}
{{- if and .Values.etcd.useExternalInstance .Values.etcd.externalInstance.secretName }}
- name: ETCDCTL_CACERT
value: "/var/contiv/etcd-secrets/caCert"
- name: ETCDCTL_CERT
value: "/var/contiv/etcd-secrets/clientCert"
- name: ETCDCTL_KEY
value: "/var/contiv/etcd-secrets/clientKey"
{{- else }}
{{- if .Values.etcd.secureTransport }}
- name: ETCDCTL_CACERT
value: "/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.caCert }}"
- name: ETCDCTL_CERT
value: "/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientCert }}"
- name: ETCDCTL_KEY
value: "/var/contiv/etcd-secrets/{{ .Values.etcd.secrets.clientKey }}"
{{- end }}
{{- end }}
- name: HOST_IP
{{- if .Values.etcd.service.useNodeIP }}
valueFrom:
fieldRef:
fieldPath: status.hostIP
{{- else }}
value: {{ $localhost_addr | quote }}
{{- end}}
{{- if .Values.Arm64Platform }}
image: {{ .Values.etcd_arm64.image.repository }}:{{ .Values.etcd_arm64.image.tag }}
{{- else }}
image: {{ .Values.etcd.image.repository }}:{{ .Values.etcd.image.tag }}
{{- end }}
command:
- /bin/sh
args:
- -c
- |
set -u
echo "$HOST_IP" | grep -q ':'
if [ "$?" -eq "0" ];
then
HOST_IP="[$HOST_IP]"
fi
{{- if not .Values.etcd.useExternalInstance }}
export ETCDCTL_ENDPOINTS="$HOST_IP:32379"
{{- end }}
until /usr/local/bin/etcdctl get "/vnf-agent/contiv-ksr/k8s/nodeconfig/$HOSTNAME" --prefix=true | grep -m 1 "$HOSTNAME";
do
echo waiting for crd node config;
sleep 1
done
{{- if .Values.etcd.secureTransport }}
volumeMounts:
- name: etcd-secrets
mountPath: /var/contiv/etcd-secrets
readOnly: true
{{- end }}
{{- end }}
# This init container extracts/copies default VPP config to the host and initializes VPP core dumps.
- name: vpp-init
{{- if .Values.Arm64Platform }}
image: {{ .Values.vswitch_arm64.image.repository }}:{{ default .Chart.Version .Values.vswitch.image.tag }}
{{- else }}
image: {{ .Values.vswitch.image.repository }}:{{ default .Chart.Version .Values.vswitch.image.tag }}
{{- end }}
imagePullPolicy: {{ .Values.vswitch.image.pullPolicy }}
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
command:
- /bin/sh
args:
- -c
- |
set -eu
chmod 700 /run/vpp
rm -rf /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api
if [ ! -e /host/etc/vpp/contiv-vswitch.conf ]; then
cp /etc/vpp/contiv-vswitch.conf /host/etc/vpp/
fi
if [ ! -d /var/run/contiv ]; then
mkdir /var/run/contiv
fi
chmod 700 /var/run/contiv
rm -f /var/run/contiv/cni.sock
if ip link show vpp1 >/dev/null 2>&1; then
ip link del vpp1
fi
cp -f /usr/local/bin/vppctl /host/usr/local/bin/vppctl
{{- if .Values.vswitch.enableCoreDumps }}
sysctl -w debug.exception-trace=1
sysctl -w kernel.core_pattern="{{ .Values.vswitch.coreDumpsDir }}/%e-%t"
ulimit -c unlimited
echo 2 > /proc/sys/fs/suid_dumpable
{{- end }}
# replace localhost IP by node IP since node port doesn't work
# on localhost IP in a certain scenario
cp /etc/etcd/etcd.conf /tmp/etcd.conf
set +e
echo "$HOST_IP" | grep -q ':'
if [ "$?" -eq "0" ];
then
HOST_IP="[$HOST_IP]"
fi
sed -i "s/__HOST_IP__/$HOST_IP/g" /tmp/etcd.conf
resources: {}
securityContext:
privileged: true
volumeMounts:
- name: usr-local-bin
mountPath: /host/usr/local/bin
- name: vpp-cfg
mountPath: /host/etc/vpp
- name: shm
mountPath: /dev/shm
- name: vpp-run
mountPath: /run/vpp
- name: contiv-run
mountPath: /var/run/contiv
- name: tmp
mountPath: /tmp
- name: etcd-cfg
mountPath: /etc/etcd
{{- if .Values.vswitch.enableCoreDumps }}
- name: core-dumps
mountPath: {{ .Values.vswitch.coreDumpsDir }}
{{- end }}
containers:
# Runs contiv-vswitch container on each Kubernetes node.
# It contains the vSwitch VPP and its management agent.
- name: contiv-vswitch
{{- if .Values.Arm64Platform }}
image: {{ .Values.vswitch_arm64.image.repository }}:{{ default .Chart.Version .Values.vswitch.image.tag }}
{{- else }}
image: {{ .Values.vswitch.image.repository }}:{{ default .Chart.Version .Values.vswitch.image.tag }}
{{- end }}
imagePullPolicy: {{ .Values.vswitch.image.pullPolicy }}
securityContext:
privileged: true
ports:
# readiness + liveness probe
- containerPort: 9999
{{- if .Values.vswitch.enableLivenessReadinessProbes }}
readinessProbe:
httpGet:
path: /readiness
port: 9999
{{- if .Values.http.enableServerCert }}
scheme: HTTPS
{{- end }}
{{- if .Values.http.enableBasicAuth }}
httpHeaders:
- name: Authorization
value: "Basic {{ .Values.http.basicAuth | b64enc }}"
{{- end }}
periodSeconds: {{ .Values.vswitch.probePeriodSeconds }}
timeoutSeconds: {{ .Values.vswitch.probeTimeoutSeconds }}
failureThreshold: {{ .Values.vswitch.probeFailureThreshold }}
initialDelaySeconds: {{ .Values.vswitch.readinessProbeInitialDelaySeconds }}
livenessProbe:
httpGet:
path: /liveness
port: 9999
{{- if .Values.http.enableServerCert }}
scheme: HTTPS
{{- end }}
{{- if .Values.http.enableBasicAuth }}
httpHeaders:
- name: Authorization
value: "Basic {{ .Values.http.basicAuth | b64enc }}"
{{- end }}
periodSeconds: {{ .Values.vswitch.probePeriodSeconds }}
timeoutSeconds: {{ .Values.vswitch.probeTimeoutSeconds }}
failureThreshold: {{ .Values.vswitch.probeFailureThreshold }}
initialDelaySeconds: {{ .Values.vswitch.livenessProbeInitialDelaySeconds }}
{{- end }}
env:
- name: MICROSERVICE_LABEL
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
{{- if not .Values.vswitch.useSocketVPPConnection }}
- name: GOVPPMUX_NOSOCK
value: "1"
{{- end }}
- name: CONTIV_CONFIG
value: "/etc/contiv/contiv.conf"
- name: CONTROLLER_CONFIG
value: "/etc/contiv/controller.conf"
- name: SERVICE_CONFIG
value: "/etc/contiv/service.conf"
- name: ETCD_CONFIG
value: "/tmp/etcd.conf"
- name: BOLT_CONFIG
value: "/etc/vpp-agent/bolt.conf"
# Uncomment to log graph traversal (very verbose):
# - name: KVSCHED_LOG_GRAPH_WALK
# value: "true"
# Uncomment to verify effect of every transaction:
# - name: KVSCHED_VERIFY_MODE
# value: "true"
{{- if .Values.bolt.debug }}
- name: DEBUG_BOLT_CLIENT
value: "true"
{{- end}}
- name: TELEMETRY_CONFIG
value: "/etc/vpp-agent/telemetry.conf"
- name: GOVPP_CONFIG
value: "/etc/vpp-agent/govpp.conf"
- name: LOGS_CONFIG
value: "/etc/vpp-agent/logs.conf"
- name: HTTP_CONFIG
value: "/etc/vpp-agent/http.conf"
- name: GRPC_CONFIG
value: "/etc/vpp-agent/grpc.conf"
- name: LINUX_IFPLUGIN_CONFIG
value: "/etc/vpp-agent/linux-ifplugin.conf"
- name: LINUX_L3PLUGIN_CONFIG
value: "/etc/vpp-agent/linux-l3plugin.conf"
- name: KVSCHEDULER_CONFIG
value: "/etc/vpp-agent/kvscheduler.conf"
- name: DISABLE_INTERFACE_STATS
value: "y"
volumeMounts:
- name: var-bolt
mountPath: /var/bolt
- name: etcd-cfg
mountPath: /etc/etcd
{{- if and .Values.etcd.useExternalInstance .Values.etcd.externalInstance.secretName }}
- name: etcd-secrets
mountPath: /var/contiv/etcd-secrets
readOnly: true
{{- else }}
{{- if .Values.etcd.secureTransport }}
- name: etcd-secrets
mountPath: /var/contiv/etcd-secrets
readOnly: true
{{- end }}
{{- end }}
{{- if .Values.http.enableServerCert }}
- name: http-secrets
mountPath: /var/http
readOnly: true
{{- end }}
- name: vpp-cfg
mountPath: /etc/vpp
- name: shm
mountPath: /dev/shm
- name: dev
mountPath: /dev
- name: sys-bus-pci
mountPath: /sys/bus/pci
- name: vpp-run
mountPath: /run/vpp
- name: contiv-run
mountPath: /var/run/contiv
- name: contiv-agent-cfg
mountPath: /etc/contiv
- name: vpp-agent-cfg
mountPath: /etc/vpp-agent
- name: tmp
mountPath: /tmp
{{- if .Values.vswitch.enableCoreDumps }}
- name: core-dumps
mountPath: {{ .Values.vswitch.coreDumpsDir }}
{{- end }}
- name: docker-socket
mountPath: /var/run/docker.sock
- name: kubelet-api
mountPath: /var/lib/kubelet
resources:
{{- if or .Values.vswitch.defineMemoryLimits .Values.vswitch.cpuLimit }}
limits:
{{- end }}
{{- if .Values.vswitch.defineMemoryLimits }}
{{- if .Values.vswitch.hugePages1giLimit }}
hugepages-1Gi: {{ .Values.vswitch.hugePages1giLimit }}
{{- else }}
{{- if .Values.vswitch.hugePages2miLimit }}
hugepages-2Mi: {{ .Values.vswitch.hugePages2miLimit }}
{{- end }}
{{- end }}
memory: {{ .Values.vswitch.memoryLimit }}
{{- end }}
{{- if .Values.vswitch.cpuLimit }}
cpu: {{ .Values.vswitch.cpuLimit }}
{{- end }}
{{- if .Values.vswitch.cpuRequest }}
requests:
cpu: {{ .Values.vswitch.cpuRequest }}
{{- end }}
volumes:
# Used to connect to contiv-etcd.
- name: etcd-cfg
configMap:
name: contiv-etcd-cfg
{{- if and .Values.etcd.useExternalInstance .Values.etcd.externalInstance.secretName }}
- name: etcd-secrets
secret:
secretName: {{ .Values.etcd.externalInstance.secretName }}
items:
- key: caCert
path: caCert
- key: clientCert
path: clientCert
- key: clientKey
path: clientKey
{{- else }}
{{- if .Values.etcd.secureTransport }}
- name: etcd-secrets
{{- if .Values.etcd.secrets.mountFromHost }}
hostPath:
path: {{ .Values.etcd.secrets.mountDir }}
{{- else }}
secret:
secretName: contiv-etcd-secrets
items:
- key: caCert
path: {{ .Values.etcd.secrets.caCert }}
- key: clientCert
path: {{ .Values.etcd.secrets.clientCert }}
- key: clientKey
path: {{ .Values.etcd.secrets.clientKey }}
{{- end }}