forked from kubernetes-sigs/cluster-api
/
clusterapiservertemplate.go
241 lines (236 loc) · 5.68 KB
/
clusterapiservertemplate.go
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
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package clusterdeployer
const ClusterAPIAPIServerConfigTemplate = `
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1alpha1.cluster.k8s.io
labels:
api: clusterapi
apiserver: "true"
spec:
version: v1alpha1
group: cluster.k8s.io
groupPriorityMinimum: 2000
priority: 200
service:
name: clusterapi
namespace: default
versionPriority: 10
caBundle: {{ .CABundle }}
---
apiVersion: v1
kind: Service
metadata:
name: clusterapi
namespace: default
labels:
api: clusterapi
apiserver: "true"
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
api: clusterapi
apiserver: "true"
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: clusterapi-apiserver
namespace: default
labels:
api: clusterapi
apiserver: "true"
spec:
replicas: 1
template:
metadata:
labels:
api: clusterapi
apiserver: "true"
spec:
nodeSelector:
node-role.kubernetes.io/master: ""
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
key: node.alpha.kubernetes.io/notReady
operator: Exists
- effect: NoExecute
key: node.alpha.kubernetes.io/unreachable
operator: Exists
containers:
- name: apiserver
image: {{ .APIServerImage }}
volumeMounts:
- name: cluster-apiserver-certs
mountPath: /apiserver.local.config/certificates
readOnly: true
- name: config
mountPath: /etc/kubernetes
- name: certs
mountPath: /etc/ssl/certs
command:
- "./apiserver"
args:
- "--etcd-servers=http://etcd-clusterapi-svc:2379"
- "--tls-cert-file=/apiserver.local.config/certificates/tls.crt"
- "--tls-private-key-file=/apiserver.local.config/certificates/tls.key"
- "--audit-log-path=-"
- "--audit-log-maxage=0"
- "--audit-log-maxbackup=0"
- "--authorization-kubeconfig=/etc/kubernetes/admin.conf"
- "--kubeconfig=/etc/kubernetes/admin.conf"
resources:
requests:
cpu: 100m
memory: 20Mi
limits:
cpu: 100m
memory: 30Mi
volumes:
- name: cluster-apiserver-certs
secret:
secretName: cluster-apiserver-certs
- name: config
hostPath:
path: /etc/kubernetes
- name: certs
hostPath:
path: /etc/ssl/certs
---
apiVersion: rbac.authorization.k8s.io/
kind: RoleBinding
metadata:
name: clusterapi
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
name: default
namespace: default
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: etcd-clusterapi
namespace: default
spec:
serviceName: "etcd"
replicas: 1
template:
metadata:
labels:
app: etcd
spec:
nodeSelector:
node-role.kubernetes.io/master: ""
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
key: node.alpha.kubernetes.io/notReady
operator: Exists
- effect: NoExecute
key: node.alpha.kubernetes.io/unreachable
operator: Exists
volumes:
- hostPath:
path: /var/lib/etcd2
type: DirectoryOrCreate
name: etcd-data-dir
terminationGracePeriodSeconds: 10
containers:
- name: etcd
image: quay.io/coreos/etcd:latest
imagePullPolicy: Always
resources:
requests:
cpu: 100m
memory: 20Mi
limits:
cpu: 100m
memory: 30Mi
env:
- name: ETCD_DATA_DIR
value: /etcd-data-dir
command:
- /usr/local/bin/etcd
- --listen-client-urls
- http://0.0.0.0:2379
- --advertise-client-urls
- http://localhost:2379
ports:
- containerPort: 2379
volumeMounts:
- name: etcd-data-dir
mountPath: /etcd-data-dir
readinessProbe:
httpGet:
port: 2379
path: /health
failureThreshold: 1
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 2
livenessProbe:
httpGet:
port: 2379
path: /health
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 2
---
apiVersion: v1
kind: Service
metadata:
name: etcd-clusterapi-svc
namespace: default
labels:
app: etcd
spec:
ports:
- port: 2379
name: etcd
targetPort: 2379
selector:
app: etcd
---
apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: cluster-apiserver-certs
namespace: default
labels:
api: clusterapi
apiserver: "true"
data:
tls.crt: {{ .TLSCrt }}
tls.key: {{ .TLSKey }}
`