kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
featureGates:
# any feature gate can be enabled here with "Name": true# or disabled here with "Name": false# not all feature gates are tested, however "CSIMigration": true
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
# WARNING: It is _strongly_ recommended that you keep this the default# (127.0.0.1) for security reasons. However it is possible to change this. apiServerAddress: "127.0.0.1"# By default the API server listens on a random open port.# You may choose a specific port but probably don't need to in most cases.# Using a random port makes it easier to spin up multiple clusters. apiServerPort: 6443
nodes:
# one node hosting a control plane- role: control-plane
您可以使用以下配置创建多节点集群
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# One control plane node and three "workers".## While these will not add more real compute capacity and# have limited isolation, this can be useful for testing# rolling updates etc.## The API-server and other control plane components will be# on the control-plane node.## You probably don't need this unless you are testing Kubernetes itself.nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
# add a mount from /path/to/my/files on the host to /files on the node extraMounts:
- hostPath: /path/to/my/files
containerPath: /files
## add an additional mount leveraging *all* of the config fields## generally you only need the two fields above ...# - hostPath: /path/to/my/other-files/
containerPath: /other-files
# optional: if set, the mount is read-only.# default false readOnly: true# optional: if set, the mount needs SELinux relabeling.# default false selinuxRelabel: false# optional: set propagation mode (None, HostToContainer or Bidirectional)# see https://kubernetes.ac.cn/docs/concepts/storage/volumes/#mount-propagation# default None## WARNING: You very likely do not need this field.## This field controls propagation of *additional* mounts created# *at runtime* underneath this mount.## On MacOS with Docker Desktop, if the mount is from macOS and not the# docker desktop VM, you cannot use this field. You can use it for# mounts to the linux VM. propagation: None
注意:如果您使用的是 Docker for Mac 或 Windows,请检查 hostPath 是否包含在首选项 -> 资源 -> 文件共享中。
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
# port forward 80 on the host to 80 on this node extraPortMappings:
- containerPort: 80
hostPort: 80
# optional: set the bind address on the host# 0.0.0.0 is the current default listenAddress: "127.0.0.1"# optional: set the protocol to one of TCP, UDP, SCTP.# TCP is the default protocol: TCP