gpt4 book ai didi

kubernetes - K8S : convert "kubeadm init" command-line arguments to "--config" YAML

转载 作者:行者123 更新时间:2023-12-02 11:39:19 25 4
gpt4 key购买 nike

背景
我正在尝试通过 kubeadm 配置集群.我通常通过以下方式创建(测试)集群:

sudo kubeadm init --pod-network-cidr 10.244.0.0/16
此参数似乎最终会进入 controllerManager ( /etc/kubernetes/manifests/kube-controller-manager.yaml ) 的静态 pod 定义:
- --cluster-cidr=10.244.0.0/16
sudo vim /etc/kubernetes/manifests/kube-controller-manager.yaml 的较大部分:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
component: kube-controller-manager
tier: control-plane
name: kube-controller-manager
namespace: kube-system
spec:
containers:
- command:
- kube-controller-manager
- --allocate-node-cidrs=true
- --authentication-kubeconfig=/etc/kubernetes/controller-manager.conf
- ...
- --cluster-cidr=10.244.0.0/16

问题 1:
我怎样才能通过这个设置, --pod-network-cidr=10.244.0.0/16通过配置文件,即 kubeadm init --config my_config.yaml ?我找到了一个 sample config file template on an unofficial K8S documentation wiki ,但我似乎根本找不到任何将这些命令行参数映射到 kubeadm 的文档。到他们的 kubeadm_config.yaml等价物。
There's also a document showing how I can create a baseline static pod definition/ yaml 来自 kubeadm config print init-defaults > kubeadm_config.yaml ,但同样,没有说明如何设置 pod-network-cidr 的文档通过修改和应用此 yaml文件(即 kubeadm upgrade -f kubeadm_config.yaml )。
kubeadm config view 的样本输出:
apiServer:
extraArgs:
authorization-mode: Node,RBAC
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.15.4
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}

问题2:
我怎么能做到以上,但通过类似 --experimental-cluster-signing-duration=0h30m0s 的东西?我想尝试涉及手动/自动更新所有 kubeadm 的测试- 相关证书。

最佳答案

1. 根据 official documentation :

It’s possible to configure kubeadm init with a configuration file instead of command line flags, and some more advanced features may only be available as configuration file options. This file is passed with the --config option.

The default configuration can be printed out using the kubeadm config print command.

It is recommended that you migrate your old v1beta1 configuration to v1beta2 using the kubeadm config migrate command.

During kubeadm init, kubeadm uploads the ClusterConfiguration object to your cluster in a ConfigMap called kubeadm-config in the kube-system namespace. This configuration is then read during kubeadm
join
, kubeadm reset and kubeadm upgrade. To view this ConfigMap call kubeadm config view.

You can use kubeadm config print to print the default configuration and kubeadm config migrate to convert your old configuration files to a newer version. kubeadm config images list and kubeadm config images pull can be used to list and pull the images that kubeadm requires.



子网由 --pod-network-cidr 定义kubeadm 或配置文件中的参数,例如下面的示例:
apiVersion: kubeadm.k8s.io/v1alpha3
kind: InitConfiguration
api:
advertiseAddress: 0.0.0.0
bindPort: 6443
kubernetesVersion: v1.12.1
---
apiVersion: kubeadm.k8s.io/v1alpha3
kind: ClusterConfiguration
networking:
podSubnet: 192.168.0.0/24

2. 我无法在官方文档或其他来源中找到类似的内容。

您可以改为使用 kube-controller-manager传递那种配置。

如果这有帮助,请告诉我。

关于kubernetes - K8S : convert "kubeadm init" command-line arguments to "--config" YAML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58276969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com