腾讯云部署Minikube

一、修改Ubuntu镜像

sudo vim /etc/apt/sources.list

追加后续镜像地址或者覆盖

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

更新并且验证

sudo apt update
sudo apt dist-upgrade

二、安装docker

卸载旧版本

sudo apt remove docker docker-engine docker.io containerd runc

设置存储库

sudo apt update

sudo apt install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

添加GPG密钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

设置稳定存储库

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

安装docker引擎

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io

运行hello-world验证是否安装正常

sudo docker run hello-world

创建docker组,Minikube需要在非root用户下使用

useradd --r -m -s /bin/bash minikube
passwd minikube
adduser minikube sudo #给用户添加管理员权限
groupadd docker
usermod -aG docker minikube
newgrp docker

root用户下:

apt install apt-transport-https
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add - 

# 设置源
cat </etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF

# 下载k8s需要的工具
apt install kubelet kubeadm kubectl

三、安装minikube

设置权限,并且移动到usr的bin目录下

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

minikube用户下:

minikube start

腾讯云部署Minikube_第1张图片
部署服务

kubectl create deployment nginx --image=nginx:1.14-alpine
kubectl expose deployment nginx --port=80 --type=NodePort  #暴露服务

kubectl port-forward svc/nginx 30000:80 --address='0.0.0.0' &  #端口转发

腾讯云中放开映射端口
在这里插入图片描述

腾讯云部署Minikube_第2张图片

四、卸载

minikube stop
minikube delete --all
docker rmi 镜像id
rm -rf ~/.kube ~/.minikube
sudo rm -rf  /usr/local/bin/minikube

五、问题归总

网上许多下面这个链接下载下来的包,在启动时拉去镜像会导致404问题,启动不了。

https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.12.1/minikube-linux-amd64

推荐使用官方地址下载

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

外网访问不到的问题需要去映射端口

kubectl port-forward svc/nginx 30000:80 --address='0.0.0.0'

你可能感兴趣的:(容器化,k8s,minikube)