Skip to content

Commit 0a662ae

Browse files
committed
feat: add pluggable component installation method
Signed-off-by: ONE7live <[email protected]>
1 parent c65778d commit 0a662ae

File tree

14 files changed

+762
-1
lines changed

14 files changed

+762
-1
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1alpha1
2+
name: node-local-dns
3+
namespace: kube-system
4+
description: A Helm chart for Kubenest plugin Node-local-dns
5+
6+
# A chart can be either an 'application' or a 'library' chart.
7+
#
8+
# Application charts are a collection of templates that can be packaged into versioned archives
9+
# to be deployed.
10+
#
11+
# Library charts provide useful utilities or functions for the chart developer. They're included as
12+
# a dependency of application charts to inject those utilities and functions into the rendering
13+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
14+
type: application
15+
16+
# This is the chart version. This version number should be incremented each time you make changes
17+
# to the chart and its templates, including the app version.
18+
version: 0.0.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application.
22+
appVersion: latest
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Node-Local-DNS
2+
3+
Kosmos-kubenest plugin NodeLocalDNS helm chart
4+
5+
## Summary
6+
7+
The chart install NodeLocalDNS set according to <https://kubernetes.io/docs/tasks/administer-cluster/nodelocaldns/>.
8+
9+
It is designed to work both with Iptables and IPVS setup.
10+
11+
Latest available `node-local-dns` image can be found at [node-local-dns google container repository](https://console.cloud.google.com/gcr/images/google-containers/GLOBAL/k8s-dns-node-cache)
12+
13+
## Values
14+
15+
| Key | Type | Default | Description |
16+
|---------------------------|------|--------------------------------------------|-------------|
17+
| image.repository | string | `"registry.k8s.io/dns/k8s-dns-node-cache"` | |
18+
| image.version | string | `"1.23.1"` | |
19+
| image.pullPolicy | string | `"IfNotPresent"` | |
20+
| config.domain | string | `"cluster.local"` | |
21+
| config.kubeDNS | string | `"xxx.xxx.xxx.xxx"` | |
22+
| config.localDNS | string | `"xxx.xxx.xxx.xxx"` | |
23+
| config.clusterDNS | string | `"xxx.xxx.xxx.xxx"` | |
24+
| resources.requests.cpu | string | `"25m"` | |
25+
| resources.requests.memory | string | `"5Mi"` | |
26+
| tolerations[0].key | string | `"CriticalAddonsOnly"` | |
27+
| tolerations[0].operator | string | `"Exists"` | |
28+
| tolerations[1].effect | string | `"NoExecute"` | |
29+
| tolerations[1].operator | string | `"Exists"` | |
30+
| tolerations[2].effect | string | `"NoSchedule"` | |
31+
| tolerations[2].operator | string | `"Exists"` | |
32+
| nodeSelector | object | `{}` | |
33+
| affinity | object | `{}` | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{- define "node-local-dns.name" -}}
2+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
3+
{{- end }}
4+
5+
{{- define "node-local-dns.namespace" -}}
6+
{{- default .Chart.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ include "node-local-dns.name" . }}
6+
namespace: {{ include "node-local-dns.namespace" . }}
7+
labels:
8+
addonmanager.kubernetes.io/mode: Reconcile
9+
data:
10+
Corefile: |
11+
{{ .Values.configMap.domain }}:53 {
12+
errors
13+
cache {
14+
success 9984 30
15+
denial 9984 5
16+
}
17+
reload
18+
loop
19+
bind {{ .Values.configMap.localDNS }} {{ .Values.configMap.kubeDNS }}
20+
forward . {{ .Values.configMap.clusterDNS }} {
21+
force_tcp
22+
}
23+
prometheus :9253
24+
health {{ .Values.configMap.localDNS }}:8080
25+
}
26+
in-addr.arpa:53 {
27+
errors
28+
cache 30
29+
reload
30+
loop
31+
bind {{ .Values.configMap.localDNS }} {{ .Values.configMap.kubeDNS }}
32+
forward . {{ .Values.configMap.clusterDNS }} {
33+
force_tcp
34+
}
35+
prometheus :9253
36+
}
37+
ip6.arpa:53 {
38+
errors
39+
cache 30
40+
reload
41+
loop
42+
bind {{ .Values.configMap.localDNS }} {{ .Values.configMap.kubeDNS }}
43+
forward . {{ .Values.configMap.clusterDNS }} {
44+
force_tcp
45+
}
46+
prometheus :9253
47+
}
48+
.:53 {
49+
errors
50+
cache 30
51+
reload
52+
loop
53+
bind {{ .Values.configMap.localDNS }} {{ .Values.configMap.kubeDNS }}
54+
forward . __PILLAR__UPSTREAM__SERVERS__
55+
prometheus :9253
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: DaemonSet
4+
metadata:
5+
name: {{ include "node-local-dns.name" . }}
6+
namespace: {{ include "node-local-dns.namespace" . }}
7+
labels:
8+
k8s-app: {{ include "node-local-dns.name" . }}
9+
kubernetes.io/cluster-service: "true"
10+
addonmanager.kubernetes.io/mode: Reconcile
11+
spec:
12+
updateStrategy:
13+
rollingUpdate:
14+
maxUnavailable: 10%
15+
selector:
16+
matchLabels:
17+
k8s-app: {{ include "node-local-dns.name" . }}
18+
template:
19+
metadata:
20+
labels:
21+
k8s-app: {{ include "node-local-dns.name" . }}
22+
annotations:
23+
prometheus.io/port: "9253"
24+
prometheus.io/scrape: "true"
25+
spec:
26+
priorityClassName: system-node-critical
27+
serviceAccountName: {{ include "node-local-dns.name" . }}
28+
hostNetwork: true
29+
dnsPolicy: Default # Don't use cluster DNS.
30+
tolerations:
31+
{{- toYaml .Values.tolerations | nindent 8 }}
32+
containers:
33+
- name: node-cache
34+
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.version }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
resources:
37+
{{- toYaml .Values.resources | nindent 12 }}
38+
args: [ "-localip", "{{ .Values.configMap.localDNS }},{{ .Values.configMap.kubeDNS }}", "-conf", "/etc/Corefile", "-upstreamsvc", "kube-dns-upstream" ]
39+
securityContext:
40+
capabilities:
41+
add:
42+
- NET_ADMIN
43+
ports:
44+
- containerPort: 53
45+
name: dns
46+
protocol: UDP
47+
- containerPort: 53
48+
name: dns-tcp
49+
protocol: TCP
50+
- containerPort: 9253
51+
name: metrics
52+
protocol: TCP
53+
livenessProbe:
54+
httpGet:
55+
host: {{ .Values.configMap.localDNS }}
56+
path: /health
57+
port: 8080
58+
initialDelaySeconds: 60
59+
timeoutSeconds: 5
60+
volumeMounts:
61+
- mountPath: /run/xtables.lock
62+
name: xtables-lock
63+
readOnly: false
64+
- name: config-volume
65+
mountPath: /etc/coredns
66+
- name: kube-dns-config
67+
mountPath: /etc/kube-dns
68+
volumes:
69+
- name: xtables-lock
70+
hostPath:
71+
path: /run/xtables.lock
72+
type: FileOrCreate
73+
- name: kube-dns-config
74+
configMap:
75+
name: kube-dns
76+
optional: true
77+
- name: config-volume
78+
configMap:
79+
name: {{ include "node-local-dns.name" . }}
80+
items:
81+
- key: Corefile
82+
path: Corefile.base
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: kube-dns-upstream
6+
namespace: {{ include "node-local-dns.namespace" . }}
7+
labels:
8+
k8s-app: kube-dns
9+
kubernetes.io/cluster-service: "true"
10+
addonmanager.kubernetes.io/mode: Reconcile
11+
kubernetes.io/name: "KubeDNSUpstream"
12+
spec:
13+
ports:
14+
- name: dns
15+
port: 53
16+
protocol: UDP
17+
targetPort: 53
18+
- name: dns-tcp
19+
port: 53
20+
protocol: TCP
21+
targetPort: 53
22+
selector:
23+
k8s-app: kube-dns
24+
---
25+
# A headless service is a service with a service IP but instead of load-balancing it will return the IPs of our associated Pods.
26+
# We use this to expose metrics to Prometheus.
27+
apiVersion: v1
28+
kind: Service
29+
metadata:
30+
annotations:
31+
prometheus.io/port: "9253"
32+
prometheus.io/scrape: "true"
33+
labels:
34+
k8s-app: {{ include "node-local-dns.name" . }}
35+
name: {{ include "node-local-dns.name" . }}
36+
namespace: {{ include "node-local-dns.namespace" . }}
37+
spec:
38+
clusterIP: None
39+
ports:
40+
- name: metrics
41+
port: 9253
42+
targetPort: 9253
43+
selector:
44+
k8s-app: {{ include "node-local-dns.name" . }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "node-local-dns.name" . }}
6+
namespace: {{ include "node-local-dns.namespace" . }}
7+
labels:
8+
kubernetes.io/cluster-service: "true"
9+
addonmanager.kubernetes.io/mode: Reconcile
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
image:
3+
repository: registry.k8s.io/dns/k8s-dns-node-cache
4+
version: 1.23.1
5+
pullPolicy: IfNotPresent
6+
---
7+
config:
8+
domain: xxx.xxx
9+
kubeDNS: xxx.xxx.xxx
10+
localDNS: xxx.xxx.xxx
11+
clusterDNS: xxx.xxx.xxx
12+
---
13+
tolerations:
14+
- key: CriticalAddonsOnly
15+
operator: Exists
16+
- effect: NoExecute
17+
operator: Exists
18+
- effect: NoSchedule
19+
operator: Exists
20+
---
21+
resources:
22+
requests:
23+
cpu: 25m
24+
memory: 5Mi
25+
---
26+
nodeSelector: {}
27+
affinity: {}

cmd/kubenest/operator/app/operator.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ func run(ctx context.Context, config *config.Config) error {
260260
KosmosClient: kosmosClient,
261261
EventRecorder: mgr.GetEventRecorderFor(constants.GlobalNodeControllerName),
262262
}
263-
264263
if err = GlobalNodeController.SetupWithManager(mgr); err != nil {
265264
return fmt.Errorf("error starting %s: %v", constants.GlobalNodeControllerName, err)
266265
}
@@ -294,6 +293,16 @@ func run(ctx context.Context, config *config.Config) error {
294293
}
295294
}
296295

296+
//VirtualClusterPluginController := vcpc.VirtualClusterPluginController{
297+
// Client: mgr.GetClient(),
298+
// RootClientSet: hostKubeClient,
299+
// KosmosClient: kosmosClient,
300+
// EventRecorder: mgr.GetEventRecorderFor(constants.PluginControllerName),
301+
//}
302+
//if err = VirtualClusterPluginController.SetupWithManager(mgr); err != nil {
303+
// return fmt.Errorf("error starting %s: %v", constants.PluginControllerName, err)
304+
//}
305+
297306
if err := mgr.Start(ctx); err != nil {
298307
return fmt.Errorf("failed to start controller manager: %v", err)
299308
}

pkg/apis/kosmos/v1alpha1/virtualclusterplugin_types.go

+18
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ type Chart struct {
5151
type Yaml struct {
5252
// +required
5353
Path Storage `json:"path"`
54+
55+
// +optional
56+
Domain string `json:"domain"`
57+
58+
// +optional
59+
KubeDNS string `json:"kubeDNS"`
60+
61+
// +optional
62+
LocalDNS string `json:"localDNS"`
63+
64+
// +optional
65+
ClusterDNS string `json:"clusterDNS"`
66+
67+
// +optional
68+
ImageRepository string `json:"imageRepository"`
69+
70+
// +optional
71+
Version string `json:"version"`
5472
}
5573

5674
type Storage struct {

pkg/kubenest/constants/constant.go

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
const (
1010
InitControllerName = "virtual-cluster-init-controller"
1111
NodeControllerName = "virtual-cluster-node-controller"
12+
PluginControllerName = "virtual-cluster-plugin-controller"
1213
GlobalNodeControllerName = "global-node-controller"
1314
KosmosJoinControllerName = "kosmos-join-controller"
1415
KosmosNs = "kosmos-system"

0 commit comments

Comments
 (0)