k8s¶
Install docker¶
sudo pacman -S docker
sudo systemctl enable --now docker.service
验证是否安装成功
docker info
docker run -it --rm archlinux bash -c "echo hello world"
登录
docker login -u <username>
设置镜像
vim /etc/docker/daemon.json
{
"registry-mirrors" : [
"http://docker.mirrors.ustc.edu.cn"
],
"insecure-registries" : [
"docker.mirrors.ustc.edu.cn"
],
"debug" : true,
"experimental" : true
}
systemctl daemon-reload
systemctl restart docker
在 Dockfile 中修改 alpine 源¶
修改项目中的Dockerfile
,在Dockerfile
中的所有 FROM ...alpine...
语句后面添加一句:
RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
其他修改 alpine 源的方法请参阅 Docker和alpine镜像内国内源配置
Install kubernates¶
sudo pacman -S etcd kubernetes-control-plane kubernetes-node
sudo pacman -S kubeadm kubelet
sudo pacman -S kubectl
Install minikube¶
sudo pacman -S minikube
配置代理¶
export HTTP_PROXY=http://<proxy hostname:port>
export HTTPS_PROXY=https://<proxy hostname:port>
export NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24
启动集群¶
minikube start
minikube dashboard
使用 echo-server 创建 Deployment¶
kubectl create deployment hello-minikube --image=registry.aliyuncs.com/google_containers/echoserver:1.10
kubectl expose deployment hello-minikube --type=NodePort --port=8080
kubectl get pod
minikube service hello-minikube --url
服务扩容¶
kubectl scale deployment hello-minikube --replicas=3
kubectl get pods
Clean Up¶
Now you can clean up the resources you created in your cluster:
kubectl delete service hello-minikube
kubectl delete deployment hello-minikube
Optionally, stop the Minikube virtual machine (VM):
minikube stop
Optionally, delete the Minikube VM:
minikube delete