ubuntu16.04安装minikube
使用原生包管理工具安装kubectl
1.更新 apt 包索引,并安装使用 Kubernetes apt 仓库所需要的包
sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl
2.下载 Google Cloud 公开签名秘钥,如果有网络问题的话,可以手动下载apt-key.gpg文件,然后将其改名并移动到/usr/share/keyrings/kubernetes-archive-keyring.gpg目录
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
3.添加 Kubernetes apt 仓库:
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
如果报错,可以使用中科大的源
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
4.更新 apt 包索引,使之包含新的仓库并安装 kubectl:
sudo apt-get update sudo apt-get install -y kubectl
参考
https://kubernetes.io/zh/docs/tasks/tools/install-kubectl-linux/
使用minikube在单机上启动一个K8S机器用于测试
https://github.com/kubernetes/minikube/releases/tag/v1.21.0
1.安装minikube
curl -LO https://github.com/kubernetes/minikube/releases/download/v1.21.0/minikube_1.21.0-0_amd64.deb sudo dpkg -i minikube_1.21.0-0_amd64.deb
2.创建集群
minikube start
如果遇到The image 'xxx' was not found; unable to add it to cache的报错,可以使用如下命令
minikube start --image-mirror-country='cn'
删除集群
minikube delete
创建特定版本的集群
minikube start --kubernetes-version=v1.21.1
3.查看集群
kubectl get po -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-64897985d-9hqwg 1/1 Running 0 20h kube-system etcd-minikube 1/1 Running 0 20h kube-system kube-apiserver-minikube 1/1 Running 0 20h kube-system kube-controller-manager-minikube 1/1 Running 0 20h kube-system kube-proxy-gzjgt 1/1 Running 0 20h kube-system kube-scheduler-minikube 1/1 Running 0 20h kube-system storage-provisioner 1/1 Running 1 (20h ago) 20h kubernetes-dashboard dashboard-metrics-scraper-58549894f-sztfp 1/1 Running 0 132m kubernetes-dashboard kubernetes-dashboard-ccd587f44-bvdc9 1/1 Running 0 132m
minikube一些命令:K8s - Install Minikube in Linux
4.启动kubernetes-dashboard,需要在图形界面中
minikube dashboard
5.配置dashboard外网访问,address是你的运行minikube的机器ip,port是对外暴露的端口
kubectl proxy --port=10018 --address='192.168.xx.xx' --accept-hosts='^.*' &
此时就可以访问如下的网址来访问minikube dashboard
http://master:10018/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/workloads?namespace=_all
参考
https://minikube.sigs.k8s.io/docs/start/
6.minikube使用ingress
https://kubernetes.io/zh-cn/docs/tasks/access-application-cluster/ingress-minikube/
本文只发表于博客园和tonglin0325的博客,作者:tonglin0325,转载请注明原文链接:https://www.cnblogs.com/tonglin0325/p/5284283.html