栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 软件开发 > 后端开发 > Java

从外部访问cluster中的pod

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

从外部访问cluster中的pod

创建cluster

创建一个新的sudo用户(此处为 rpod),并切换至此用户下

sudo adduser rpod
sudo usermod -aG sudo rpod
su - rpod

安装docker

sudo apt-get update
sudo apt-get install -qy docker.io

此时会出现报错

E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 21410 (unattended-upgr)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

终止被占用的process(此处终止了两次)

sudo kill -9 21410

再进行安装

sudo apt-get install -qy docker.io

安装kubelet, kubeadm 和 kubernetes-cni

$sudo apt-get update
$sudo apt-get install -y apt-transport-https
$curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list 
$sudo apt-get update
$ sudo apt-get install -yq kubelet kubeadm kubernetes-cni
$ sudo apt-mark hold kubelet kubeadm kubectl

关闭swap

sudo swapoff -a

检查是否存在未关闭的,完成后输出如下

cat /proc/swaps
Filename				Type		Size		Used		Priority

用  ifconfig 查看IP地址

$ ifconfig
docker0: flags=4099  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:15:41:ff:4f  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163  mtu 1500
        inet 192.168.234.128  netmask 255.255.255.0  broadcast 192.168.234.255
        inet6 fe80::8100:f7d8:787e:d5ac  prefixlen 64  scopeid 0x20
        ether 00:0c:29:ab:c6:2c  txqueuelen 1000  (Ethernet)
        RX packets 3088934  bytes 4524632346 (4.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 443482  bytes 27811821 (27.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4608  bytes 472107 (472.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4608  bytes 472107 (472.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

初始化 kubeadm

$sudo kubeadm init --apiserver-advertise-address=192.168.234.128 --kubernetes-version stable-1.26

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 192.168.234.128:6443 --token cj5qa7.rjhffasmq6xy48pm 
	--discovery-token-ca-cert-hash sha256:1c1d71d6dd0d22463bc1185c7d8575bca06051b6b9834372131fee195a3ece10 

转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/1039682.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号