🌹
My GitBook
  • README
  • ai
    • Python 人工智能 5秒钟偷走你的声音
    • Python安装-在Linux系统中使用编译进行安装
    • 人工智能NVIDIA显卡计算(CUDA+CUDNN)平台搭建
    • 人工智能 deepface 换脸技术 学习
    • 华为 A800-9000 服务器 离线安装MindX DL
    • 华为 A800-9000 服务器 离线安装MindX DL 可视化环境+监控
    • 华为人工智能atlasA800-9000物理服务器离线安装及CANN安装和MindSpore安装和Tensorflow安装
  • docker
    • Containerd 入门基础操作
    • Docker启动MySQL、MongoDB、Redis、Elasticsearch、Grafana,数据库
    • Docker容器中使用GPU
    • docker方式实现minio数据持久化离线安装
    • docker方式实现postgres数据持久化离线安装
    • docker方式实现redis数据持久化离线安装
    • 使用二进制方式安装Docker
    • 学习docker看此文足以
  • kubernetes_install
    • Enable-implement-IPv4-IPv6
    • Kubernetes 1.24 1.25 集群使用docker作为容器
    • 安装Minikube并启动一个Kubernetes环境
    • 升级二进制kubernetes集群
    • 修复kube-proxy证书权限过大问题
    • kubeadm-install-IPV6-IPV4
    • kubernetes 安装cilium
    • v1.21.13-CentOS-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.22.10-CentOS-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.23.3-CentOS-binary-install
    • v1.23.4-CentOS-binary-install
    • v1.23.5-CentOS-binary-install
    • v1.23.6-CentOS-binary-install
    • v1.23.7-CentOS-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.24.0-CentOS-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.24.0-CentOS-binary-install-IPv6-IPv4
    • v1.24.1-CentOS-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.24.1-CentOS-binary-install-IPv6-IPv4
    • v1.24.1-Ubuntu-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.24.2-CentOS-binary-install-IPv6-IPv4
    • v1.24.3-CentOS-binary-install-IPv6-IPv4
    • v1.25.0-CentOS-binary-install-IPv6-IPv4-Three-Masters-Two-Slaves
    • v1.25.0-CentOS-binary-install-IPv6-IPv4
  • kubernetes_other
    • Kubernetes 1.24 1.25 集群使用docker作为容器
    • Kubernetes 各个组件 启动参数介绍
    • Kubernetes 部署 MySQL 集群
    • 在 Kubernetes 集群上部署 VSCode
    • 在Kubernetes上安装Netdata的方法
    • 在Kubernetes部署GitLab
    • Kubernetes(K8S)内核优化常用参数详解
    • 在Kubernetes(k8s)中使用GPU
    • 在Kubernetes(k8s)中部署 jenkins
    • Kubernetes(k8s)实现IPv4/IPv6网络双栈
    • Kubernetes(k8s)集群安装JupyterHub以及Lab
    • k8s加入新的master节点出现etcd检查失败
    • k8s集群进行删除并添加node节点
    • 在k8s(kubernetes) 上安装 ingress V1.1.0
    • 在k8s(kubernetes)上安装 ingress V1.1.3
    • 在 k8s(kubernetes)中使用 Loki 进行日志监控
    • kube-apiserver启动命令参数解释
    • kubectl管理多个集群配置
    • kubernetes(k8s) 存储动态挂载
    • kubernetes (k8s) 二进制高可用安装
    • kubernetes 启用 PHP + Nginx 网页环境
    • kubernetes 安装 Prometheus + Grafana
    • kubernetes 安装cilium
    • kubernetes 的TCP 数据包可视化
    • kubernetes 设置 Master 可调度与不可调度
    • kubernetes (k8s) v1.24.0 安装dashboard面板
    • kubernetes(k8s) 中安装kuboard面板
    • kubernetes(k8s) 安装 Prometheus + Grafana
    • kubernetes(k8s)中部署 efk
    • kubernetes(k8s)中部署dashboard可视化面板
    • 为kubernetes(k8s)单独配置kubectl工具
    • kubernetes(k8s)命名空间一直Terminating
    • kubernetes(k8s)安装BGP模式calico网络支持IPV4和IPV6
    • kubernetes(k8s)安装命令行自动补全功能
    • kubernetes(k8s)常用deploy模板 并验证
    • kubernetes(k8s)部署 Metrics Server 资源
    • 使用Kubernetes快速启用一个静态页面
    • 使用 Istioctl 安装 istio
    • 使用kubeadm初始化IPV4/IPV6集群
    • 使用kubeadm快速启用一个集群
    • 修复kube-proxy证书权限过大问题
    • 关于 ServiceAccounts 及其 Secrets 的重大变化
    • 创建用户认证授权的 kubeconfig 文件
    • 利用 kubeadm 创建 kubernetes 的高可用集群
    • 升级二进制kubernetes集群
    • 在k8s上安装Harbor
    • 在k8s安装CICD-devtron
    • 安装KubeOperator并导入现有集群进行管理
    • 安装Minikube并启动一个Kubernetes环境
    • 安装 Metrics server
    • 经GitHub将kubernetes镜像推送到阿里云
    • 自编写二进制安装kubernetes脚本v2.0版本
    • 部署kubernetes官网博客
  • kubesphere
    • 在 Linux 上以 All-in-One 模式安装 KubeSphere
    • KubeSphere 升级 && 安装后启用插件
    • KubeSphere 高可用集群搭建并启用所有插件
    • ​KubeSphere离线无网络环境部署
  • linux
    • Ansible 安装并简单使用
    • CentOS&RHEL内核升级
    • CentOS8删除boot目录恢复
    • CentOS 9 开局配置
    • CentOS 的 YUM安装时卡死解决方案
    • CentOS安装时钟同步服务
    • Centos9网卡配置
    • Exchangis搭建安装
    • GitHub+Hexo 搭建博客网站
    • GitLab 安装部署使用
    • Git命令简单使用
    • Grafana Prometheus Altermanager 监控系统
    • HaProxy 安装搭建配置
    • KVM WEB管理工具 WebVirtMgr
    • Let's Encrypt 泛域名证书申请
    • Linux内核高性能优化
    • Linux文件系统故障,Input/output error
    • Linux磁盘LVM根目录扩容
    • MINIO搭建单机以及集群
    • MySQL8.0允许外部访问
    • Nginx主要功能
    • OpenWRT实现NAT64/DNS64
    • PVE开启硬件显卡直通功能
    • Prometheus+Grafana监控系统
    • Proxmox VE镜像分析与定制
    • SELinux入门学习总结
    • Ubuntu 通过 Netplan 配置网络教程
    • 在Ubuntu中安装Samba文件服务
    • YUM下载全量依赖
    • elk7.15.1安装部署搭建
    • 一键部署十个服务脚本--可拆分---java+mysql+redis+nginx+rocketmq..等等
    • 从APNIC获取中国IP地址列表
    • 使用HTMLform表单操作腾讯云DNS控制台
    • 使用frp进行内网穿透
    • 修复Joe主题静态资源为国内地址
    • 内网搭建DNS服务器
    • 利用NGINX搭建部署直播流媒体服务器
    • 在线编写Markdown
    • 安装Harbor
    • 安装部署keepalived的HA环境
    • 快速部署Ceph分布式高可用集群
    • 搭建DHCP服务,实现自动分配地址
    • 搭建Hadoop2.7.2和Hive2.3.3以及Spark3.1.2
    • 搭建一个自己专属的个人网盘
    • 最新版 Harbor 在ubuntu系统上安装
    • 服务器被入侵,异常进程无法杀掉,随机进程名
    • 系统优化脚本支持Ubuntu和CentOS
    • 网络抓包 tcpdump 使用指南
    • 腾讯蓝鲸集群式部署
    • 部署lnmp环境,安装typecho博客
    • 镜像搬运工 skopeo
由 GitBook 提供支持
在本页
  • 使用kubeadm初始化IPV4/IPV6集群
  • CentOS 配置YUM源
  • Ubuntu 配置APT源
  • 配置containerd
  • 配置基础环境
  • 初始化安装
  • 查看集群
  • 配置calico
  • 测试IPV6
在GitHub上编辑
  1. kubernetes_other

使用kubeadm初始化IPV4/IPV6集群

上一页使用 Istioctl 安装 istio下一页使用kubeadm快速启用一个集群

最后更新于2年前

使用kubeadm初始化IPV4/IPV6集群

图片

图片

CentOS 配置YUM源

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=kubernetes
baseurl=https://mirrors.ustc.edu.cn/kubernetes/yum/repos/kubernetes-el7-$basearch
enabled=1
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl

# 如安装老版本
# yum install kubelet-1.16.9-0 kubeadm-1.16.9-0 kubectl-1.16.9-0

systemctl enable kubelet && systemctl start kubelet


# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
sudo systemctl enable --now kubelet

Ubuntu 配置APT源

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl

# 如安装老版本
# apt install kubelet=1.23.6-00 kubeadm=1.23.6-00 kubectl=1.23.6-00

配置containerd

wget https://github.com/containerd/containerd/releases/download/v1.6.4/cri-containerd-cni-1.6.4-linux-amd64.tar.gz

#解压
tar -C / -xzf cri-containerd-cni-1.6.4-linux-amd64.tar.gz

#创建服务启动文件
cat > /etc/systemd/system/containerd.service <<EOF
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
TasksMax=infinity
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target
EOF


mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml

sed -i "s#SystemdCgroup\ \=\ false#SystemdCgroup\ \=\ true#g" /etc/containerd/config.toml
sed -i "s#k8s.gcr.io#registry.cn-hangzhou.aliyuncs.com/chenby#g" /etc/containerd/config.toml

systemctl daemon-reload
systemctl enable --now containerd

配置基础环境

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
fs.may_detach_mounts = 1
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_watches=89100
fs.file-max=52706963
fs.nr_open=52706963
net.netfilter.nf_conntrack_max=2310720


net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl =15
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 327680
net.ipv4.tcp_orphan_retries = 3
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.ip_conntrack_max = 65536
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_timestamps = 0
net.core.somaxconn = 16384


net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.all.forwarding = 1
EOF


modprobe br_netfilter

sudo sysctl --system


hostnamectl set-hostname k8s-master01
hostnamectl set-hostname k8s-node01
hostnamectl set-hostname k8s-node02


sed -ri 's/.*swap.*/#&/' /etc/fstab
swapoff -a && sysctl -w vm.swappiness=0

cat /etc/fstab






cat > /etc/hosts <<EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

2408:8207:78ce:7561::21 k8s-master01
2408:8207:78ce:7561::22 k8s-node01
2408:8207:78ce:7561::23 k8s-node02

10.0.0.21 k8s-master01
10.0.0.22 k8s-node01
10.0.0.23 k8s-node02
EOF

初始化安装

root@k8s-master01:~# kubeadm config images list --image-repository registry.cn-hangzhou.aliyuncs.com/chenby
registry.cn-hangzhou.aliyuncs.com/chenby/kube-apiserver:v1.24.0
registry.cn-hangzhou.aliyuncs.com/chenby/kube-controller-manager:v1.24.0
registry.cn-hangzhou.aliyuncs.com/chenby/kube-scheduler:v1.24.0
registry.cn-hangzhou.aliyuncs.com/chenby/kube-proxy:v1.24.0
registry.cn-hangzhou.aliyuncs.com/chenby/pause:3.7
registry.cn-hangzhou.aliyuncs.com/chenby/etcd:3.5.3-0
registry.cn-hangzhou.aliyuncs.com/chenby/coredns:v1.8.6

root@k8s-master01:~# vim kubeadm.yaml 
root@k8s-master01:~# cat kubeadm.yaml
apiVersion: kubeadm.k8s.io/v1beta3
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: "10.0.0.21"
  bindPort: 6443
nodeRegistration:
  taints:
  - effect: PreferNoSchedule
    key: node-role.kubernetes.io/master
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
kubernetesVersion: v1.24.0
imageRepository: registry.cn-hangzhou.aliyuncs.com/chenby
networking:
  podSubnet: 172.16.0.0/12,fc00::/48
  serviceSubnet: 10.96.0.0/12,fd00::/108
root@k8s-master01:~#


root@k8s-master01:~# 
root@k8s-master01:~# kubeadm init --config=kubeadm.yaml 
[init] Using Kubernetes version: v1.24.0
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-master01 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.0.0.21]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-master01 localhost] and IPs [10.0.0.21 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-master01 localhost] and IPs [10.0.0.21 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 6.504341 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node k8s-master01 as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node k8s-master01 as control-plane by adding the taints [node-role.kubernetes.io/master:PreferNoSchedule]
[bootstrap-token] Using token: lnodkp.3n8i4m33sqwg39w2
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 10.0.0.21:6443 --token lnodkp.3n8i4m33sqwg39w2 \
    --discovery-token-ca-cert-hash sha256:0ed7e18ea2b49bb599bc45e72f764bbe034ef1dce47729f2722467c167754da8 
root@k8s-master01:~# 
root@k8s-master01:~#   mkdir -p $HOME/.kube
root@k8s-master01:~#   sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
root@k8s-master01:~#   sudo chown $(id -u):$(id -g) $HOME/.kube/config
root@k8s-master01:~# 




root@k8s-node01:~# kubeadm join 10.0.0.21:6443 --token qf3z22.qwtqieutbkik6dy4 \
> --discovery-token-ca-cert-hash sha256:2ade8c834a41cc1960993a600c89fa4bb86e3594f82e09bcd42633d4defbda0d
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

root@k8s-node01:~# 


root@k8s-node02:~# kubeadm join 10.0.0.21:6443 --token qf3z22.qwtqieutbkik6dy4 \
> --discovery-token-ca-cert-hash sha256:2ade8c834a41cc1960993a600c89fa4bb86e3594f82e09bcd42633d4defbda0d
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

root@k8s-node02:~# 

查看集群

root@k8s-master01:~# kubectl  get node
NAME           STATUS   ROLES           AGE    VERSION
k8s-master01   Ready    control-plane   111s   v1.24.0
k8s-node01     Ready    <none>          82s    v1.24.0
k8s-node02     Ready    <none>          92s    v1.24.0
root@k8s-master01:~# 
root@k8s-master01:~# 
root@k8s-master01:~# kubectl  get pod -A
NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
kube-system   coredns-bc77466fc-jxkpv                1/1     Running   0          83s
kube-system   coredns-bc77466fc-nrc9l                1/1     Running   0          83s
kube-system   etcd-k8s-master01                      1/1     Running   0          87s
kube-system   kube-apiserver-k8s-master01            1/1     Running   0          89s
kube-system   kube-controller-manager-k8s-master01   1/1     Running   0          87s
kube-system   kube-proxy-2lgrn                       1/1     Running   0          83s
kube-system   kube-proxy-69p9r                       1/1     Running   0          47s
kube-system   kube-proxy-g58m2                       1/1     Running   0          42s
kube-system   kube-scheduler-k8s-master01            1/1     Running   0          87s
root@k8s-master01:~# 

配置calico

wget https://raw.githubusercontent.com/cby-chen/Kubernetes/main/yaml/calico-ipv6.yaml

# vim calico-ipv6.yaml
# calico-config ConfigMap处
    "ipam": {
        "type": "calico-ipam",
        "assign_ipv4": "true",
        "assign_ipv6": "true"
    },
    - name: IP
      value: "autodetect"

    - name: IP6
      value: "autodetect"

    - name: CALICO_IPV4POOL_CIDR
      value: "172.16.0.0/16"

    - name: CALICO_IPV6POOL_CIDR
      value: "fc00::/48"

    - name: FELIX_IPV6SUPPORT
      value: "true"

kubectl  apply -f calico-ipv6.yaml 

测试IPV6

root@k8s-master01:~# cat cby.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chenby
spec:
  replicas: 3
  selector:
    matchLabels:
      app: chenby
  template:
    metadata:
      labels:
        app: chenby
    spec:
      containers:
      - name: chenby
        image: nginx
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: chenby
spec:
  ipFamilyPolicy: PreferDualStack
  ipFamilies:
  - IPv6
  - IPv4
  type: NodePort
  selector:
    app: chenby
  ports:
  - port: 80
    targetPort: 80

kubectl  apply -f cby.yaml 

root@k8s-master01:~# kubectl  get pod 
NAME                      READY   STATUS    RESTARTS   AGE
chenby-57479d5997-6pfzg   1/1     Running   0          6m
chenby-57479d5997-jjwpk   1/1     Running   0          6m
chenby-57479d5997-pzrkc   1/1     Running   0          6m

root@k8s-master01:~# kubectl  get svc
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
chenby       NodePort    fd00::f816   <none>        80:30265/TCP   6m7s
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP        168m

root@k8s-master01:~# curl -I http://[2408:8207:78ce:7561::21]:30265/
HTTP/1.1 200 OK
Server: nginx/1.21.6
Date: Wed, 11 May 2022 07:01:43 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 25 Jan 2022 15:03:52 GMT
Connection: keep-alive
ETag: "61f01158-267"
Accept-Ranges: bytes

root@k8s-master01:~# curl -I http://10.0.0.21:30265/
HTTP/1.1 200 OK
Server: nginx/1.21.6
Date: Wed, 11 May 2022 07:01:54 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 25 Jan 2022 15:03:52 GMT
Connection: keep-alive
ETag: "61f01158-267"
Accept-Ranges: bytes

https://www.oiox.cn/

https://www.chenby.cn/

https://blog.oiox.cn/

https://cby-chen.github.io/

https://blog.csdn.net/qq_33921750

https://my.oschina.net/u/3981543

https://www.zhihu.com/people/chen-bu-yun-2

https://segmentfault.com/u/hppyvyv6/articles

https://juejin.cn/user/3315782802482007

https://cloud.tencent.com/developer/column/93230

https://www.jianshu.com/u/0f894314ae2c

https://www.toutiao.com/c/user/token/MS4wLjABAAAAeqOrhjsoRZSj7iBJbjLJyMwYT5D0mLOgCoo4pEmpr4A/

CSDN、GitHub、知乎、开源中国、思否、掘金、简书、腾讯云、今日头条、个人博客、全网可搜《小陈运维》

文章主要发布于微信:《Linux运维交流社区》