1。安装kubeadm
版本一定要是1.26
1.25的kubelet有bug
早于1.23的版本无法编译kanative
(都是血泪教训呜呜呜
https://blog.csdn.net/yudaxiaye/article/details/126919267
sudo apt install -y apt-transport-https ca-certificates curl
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
sudo apt update
sudo apt install -y kubeadm=1.26.1-00 kubelet=1.26.1-00 kubectl=1.26.1-00
2。安装运行时(1.23后docker不是默认的了,我这里装了containerd
containerd安装脚本我写好了(python)
需要提前把几个安装包准备好:
cni,containerd,runc,containerd.service
import subprocess
import os
import shutil
def copy_file():
shutil.copy('文件的名字', '复制的路径位置')
def runcmd(cmd):
ret=subprocess.run(cmd.split(" "))
if ret.returncode==0:
print(">>> ",cmd," succ \n")
else:
print(">>> ",cmd," fail ",ret,"\n")
def trydo(cb):
try:
cb()
finally:
print("")
trydo(
lambda:runcmd("tar Cxzvf /usr/local containerd-1.6.15-linux-amd64.tar.gz")
)
shutil.copy("./containerd.service","/etc/systemd/system")
runcmd("systemctl daemon-reload")
runcmd("systemctl enable --now containerd")
runcmd("install -m 755 runc.amd64 /usr/local/sbin/runc")
runcmd("mkdir -p /opt/cni/bin")
trydo(
lambda:runcmd("tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.2.0.tgz")
)
3。创建集群
首先需要有个配置文件
关键的几个地方:
advertiseAddress //专门用来访问的ip,可以是本地,外网,zerotier
imageRepository //国内访问需要代理镜像
apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.193.3
bindPort: 6443
nodeRegistration:
# criSocket: /var/run/dockershim.sock
imagePullPolicy: IfNotPresent
name: MasterNode
taints: null
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns: {}
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: 1.26.0
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
scheduler: {}
4.knative 开发环境安装
部署完照着knative步骤做就行了
https://github.com/knative/serving/blob/main/DEVELOPMENT.md
需要.ko.yaml 修改成 defaultBaseImage: docker.io/ubuntu
go语言版本1.19 需要设置环境变量:GOFLAGS=-buildvcs=false
具体见:https://github.com/knative/serving/discussions/13647#discussioncomment-4778471