|
| 1 | +/* |
| 2 | +Copyright 2024 The Kubernetes Authors All rights reserved. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package ktmpl |
| 18 | + |
| 19 | +import "text/template" |
| 20 | + |
| 21 | +// V1Beta4 is kubeadm config template for Kubernetes v1.31.0+ |
| 22 | +var V1Beta4 = template.Must(template.New("configTmpl-v1beta4").Funcs(template.FuncMap{ |
| 23 | + "printMapInOrder": printMapInOrder, |
| 24 | +}).Parse(`apiVersion: kubeadm.k8s.io/v1beta4 |
| 25 | +kind: InitConfiguration |
| 26 | +localAPIEndpoint: |
| 27 | + advertiseAddress: {{.AdvertiseAddress}} |
| 28 | + bindPort: {{.APIServerPort}} |
| 29 | +bootstrapTokens: |
| 30 | + - groups: |
| 31 | + - system:bootstrappers:kubeadm:default-node-token |
| 32 | + ttl: 24h0m0s |
| 33 | + usages: |
| 34 | + - signing |
| 35 | + - authentication |
| 36 | +nodeRegistration: |
| 37 | + criSocket: {{if .CRISocket}}{{if .PrependCriSocketUnix}}unix://{{end}}{{.CRISocket}}{{else}}{{if .PrependCriSocketUnix}}unix://{{end}}/var/run/dockershim.sock{{end}} |
| 38 | + name: "{{.NodeName}}" |
| 39 | + kubeletExtraArgs: |
| 40 | + - name: "node-ip" |
| 41 | + value: "{{.NodeIP}}" |
| 42 | + taints: [] |
| 43 | +--- |
| 44 | +apiVersion: kubeadm.k8s.io/v1beta4 |
| 45 | +kind: ClusterConfiguration |
| 46 | +{{ if .ImageRepository}}imageRepository: {{.ImageRepository}} |
| 47 | +{{end}}{{range .ComponentOptions}}{{.Component}}: |
| 48 | +{{- range $k, $v := .Pairs }} |
| 49 | + {{$k}}: {{$v}} |
| 50 | +{{- end}} |
| 51 | + extraArgs: |
| 52 | +{{- range $key, $val := .ExtraArgs }} |
| 53 | + - name: "{{$key}}" |
| 54 | + value: "{{$val}}" |
| 55 | +{{- end}} |
| 56 | +{{end -}} |
| 57 | +{{if .FeatureArgs}}featureGates: |
| 58 | +{{range $i, $val := .FeatureArgs}}{{$i}}: {{$val}} |
| 59 | +{{end -}}{{end -}} |
| 60 | +certificatesDir: {{.CertDir}} |
| 61 | +clusterName: mk |
| 62 | +controlPlaneEndpoint: {{.ControlPlaneAddress}}:{{.APIServerPort}} |
| 63 | +etcd: |
| 64 | + local: |
| 65 | + dataDir: {{.EtcdDataDir}} |
| 66 | + extraArgs: |
| 67 | + - name: "proxy-refresh-interval" |
| 68 | + value: "70000" |
| 69 | +{{- range $key, $val := .EtcdExtraArgs }} |
| 70 | + - name: "{{$key}}" |
| 71 | + value: "{{$val}}" |
| 72 | +{{- end}} |
| 73 | +kubernetesVersion: {{.KubernetesVersion}} |
| 74 | +networking: |
| 75 | + dnsDomain: {{if .DNSDomain}}{{.DNSDomain}}{{else}}cluster.local{{end}} |
| 76 | + podSubnet: "{{.PodSubnet }}" |
| 77 | + serviceSubnet: {{.ServiceCIDR}} |
| 78 | +--- |
| 79 | +apiVersion: kubelet.config.k8s.io/v1beta1 |
| 80 | +kind: KubeletConfiguration |
| 81 | +authentication: |
| 82 | + x509: |
| 83 | + clientCAFile: {{.ClientCAFile}} |
| 84 | +cgroupDriver: {{.CgroupDriver}} |
| 85 | +{{- range $key, $val := .KubeletConfigOpts}} |
| 86 | +{{$key}}: {{$val}} |
| 87 | +{{- end}} |
| 88 | +clusterDomain: "{{if .DNSDomain}}{{.DNSDomain}}{{else}}cluster.local{{end}}" |
| 89 | +# disable disk resource management by default |
| 90 | +imageGCHighThresholdPercent: 100 |
| 91 | +evictionHard: |
| 92 | + nodefs.available: "0%" |
| 93 | + nodefs.inodesFree: "0%" |
| 94 | + imagefs.available: "0%" |
| 95 | +failSwapOn: false |
| 96 | +staticPodPath: {{.StaticPodPath}}{{if .ResolvConfSearchRegression}} |
| 97 | +resolvConf: /etc/kubelet-resolv.conf{{end}} |
| 98 | +--- |
| 99 | +apiVersion: kubeproxy.config.k8s.io/v1alpha1 |
| 100 | +kind: KubeProxyConfiguration |
| 101 | +clusterCIDR: "{{.PodSubnet }}" |
| 102 | +metricsBindAddress: 0.0.0.0:10249 |
| 103 | +conntrack: |
| 104 | + maxPerCore: 0 |
| 105 | +# Skip setting "net.netfilter.nf_conntrack_tcp_timeout_established" |
| 106 | + tcpEstablishedTimeout: 0s |
| 107 | +# Skip setting "net.netfilter.nf_conntrack_tcp_timeout_close" |
| 108 | + tcpCloseWaitTimeout: 0s |
| 109 | +{{- range $i, $val := printMapInOrder .KubeProxyOptions ": " }} |
| 110 | +{{$val}} |
| 111 | +{{- end}} |
| 112 | +`)) |
0 commit comments