說下為啥選擇云環(huán)境,最開始在本地電腦上安裝的minikube,但是由于國內(nèi)的網(wǎng)絡(luò)訪問不了谷歌的鏡像倉庫,安裝ingress-nginx或者其他插件時(shí)著實(shí)的惡心。要不翻墻,要不自己搭建個(gè)鏡像倉庫。最終決定用阿里云境外的節(jié)點(diǎn),按小時(shí)收費(fèi)的那種,一個(gè)小時(shí)大概也就3毛錢。隨時(shí)釋放,不會(huì)因?yàn)檫@些環(huán)境和網(wǎng)絡(luò)的問題分神。
1.準(zhǔn)備環(huán)境
阿里云登錄 - 歡迎登錄阿里云,安全穩(wěn)定的云計(jì)算服務(wù)平臺(tái)
沒有賬號(hào)注冊(cè)一個(gè),或者使用支付寶登陸。這里就不做贅述了。
選擇“云服務(wù)ECS”
?創(chuàng)建實(shí)例
一定選擇國外的節(jié)點(diǎn)?,我選擇是韓國首爾的節(jié)點(diǎn),這個(gè)便宜。CPU2核,內(nèi)存2G。操作系統(tǒng)選的是ubuntu18.04(看自己喜好linux哪個(gè)都行),磁盤不用修改40G和20G一樣錢。
?
下一步網(wǎng)絡(luò)設(shè)置。需要自建一個(gè)交換機(jī)和安全組,就按推薦的建。分配公網(wǎng)IP選上,按流量收費(fèi)。
?
?下一步系統(tǒng)配置,配置自定義密碼登陸的方式,給root用戶設(shè)置一個(gè)秘密,設(shè)置個(gè)自己喜歡的。
?確認(rèn)訂單。創(chuàng)建實(shí)例。賬戶需要有100塊錢(按時(shí)間扣費(fèi)用)。
?
?控制臺(tái)多了剛才創(chuàng)建的實(shí)例,我剛新建的外網(wǎng)ip是8.213.130.127(基本用幾個(gè)小時(shí)我就釋放了,不怕暴露),此時(shí)在你機(jī)器的本地就可以通過ssh對(duì)這臺(tái)機(jī)器登陸了。
補(bǔ)充下安全組,默認(rèn)創(chuàng)建的安全組會(huì)開放22、80端口,所以本機(jī)才可以使用ssh登陸。
?本地登陸
ssh root@8.213.130.127
?2.安裝docker
apt-get update
apt install docker.io
root@iZmj7hlj4my4j4dgaiq763Z:~# apt install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
bridge-utils containerd dns-root-data dnsmasq-base git git-man libcurl3-gnutls liberror-perl pigz runc ubuntu-fan
Suggested packages:
ifupdown aufs-tools btrfs-progs cgroupfs-mount | cgroup-lite debootstrap docker-doc rinse zfs-fuse | zfsutils git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs
git-mediawiki git-svn
The following NEW packages will be installed:
bridge-utils containerd dns-root-data dnsmasq-base docker.io git git-man libcurl3-gnutls liberror-perl pigz runc ubuntu-fan
0 upgraded, 12 newly installed, 0 to remove and 55 not upgraded.
Need to get 71.0 MB of archives.
After this operation, 327 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Y就行了。安裝完查看docker版本
root@iZmj7hlj4my4j4dgaiq763Z:~# docker -v
Docker version 20.10.21, build 20.10.21-0ubuntu1~18.04.2
?3.安裝minikube
Welcome! | minikube
可以參考官網(wǎng)。選擇下Linux、x86-64、stable、binary download
?curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
?下載安裝包
root@iZmj7hlj4my4j4dgaiq763Z:~# curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 80.0M 100 80.0M 0 0 9874k 0 0:00:08 0:00:08 --:--:-- 12.2M
安裝
sudo install minikube-linux-amd64 /usr/local/bin/minikube
啟動(dòng)
minikube start
提示xxx,直接加一個(gè)--force。
root@iZmj7hlj4my4j4dgaiq763Z:~# minikube start
?? minikube v1.30.1 on Ubuntu 18.04 (amd64)
? Automatically selected the docker driver. Other choices: ssh, none
?? The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
?? If you are running minikube within a VM, consider using --driver=none:
?? https://minikube.sigs.k8s.io/docs/reference/drivers/none/
? Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.
minikube start --force
啟動(dòng)成功,還有一個(gè)提示是內(nèi)存小于最小內(nèi)存1900MB了。學(xué)習(xí)環(huán)境不用理這個(gè)錯(cuò)誤。
root@iZmj7hlj4my4j4dgaiq763Z:~# minikube start --force
?? minikube v1.30.1 on Ubuntu 18.04 (amd64)
? minikube skips various validations when --force is supplied; this may lead to unexpected behavior
? Automatically selected the docker driver. Other choices: none, ssh
?? The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
?? If you are running minikube within a VM, consider using --driver=none:
?? https://minikube.sigs.k8s.io/docs/reference/drivers/none/
? Requested memory allocation (1889MB) is less than the recommended minimum 1900MB. Deployments may fail.
?? The requested memory allocation of 1889MiB does not leave room for system overhead (total system memory: 1889MiB). You may face stability issues.
?? Suggestion: Start minikube with less memory allocated: 'minikube start --memory=1889mb'
?? Using Docker driver with root privileges
?? Starting control plane node minikube in cluster minikube
?? Pulling base image ...
?? Downloading Kubernetes v1.26.3 preload ...
> preloaded-images-k8s-v18-v1...: 397.02 MiB / 397.02 MiB 100.00% 6.80 Mi
> gcr.io/k8s-minikube/kicbase...: 373.53 MiB / 373.53 MiB 100.00% 4.50 Mi
?? Creating docker container (CPUs=2, Memory=1889MB) ...
?? Preparing Kubernetes v1.26.3 on Docker 23.0.2 ...
? Generating certificates and keys ...
? Booting up control plane ...
? Configuring RBAC rules ...
?? Configuring bridge CNI (Container Networking Interface) ...
? Using image gcr.io/k8s-minikube/storage-provisioner:v5
?? Verifying Kubernetes components...
?? Enabled addons: storage-provisioner, default-storageclass
?? kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
?? Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
?3.安裝kubectl
在 Linux 系統(tǒng)中安裝并設(shè)置 kubectl | Kubernetes
curl -LO https://dl.k8s.io/release/v1.26.0/bin/linux/amd64/kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
查看版本
kubectl version
root@iZmj7hlj4my4j4dgaiq763Z:~# kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.0", GitCommit:"b46a3f887ca979b1a5d14fd39cb1af43e7e5d12d", GitTreeState:"clean", BuildDate:"2022-12-08T19:58:30Z", GoVersion:"go1.19.4", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.3", GitCommit:"9e644106593f3f4aa98f8a84b23db5fa378900bd", GitTreeState:"clean", BuildDate:"2023-03-15T13:33:12Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
4.通過kubectl查看剛啟動(dòng)minikube
kubectl get pod -A
root@iZmj7hlj4my4j4dgaiq763Z:~# kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-787d4945fb-dxzrl 1/1 Running 0 5m12s
kube-system etcd-minikube 1/1 Running 0 5m24s
kube-system kube-apiserver-minikube 1/1 Running 0 5m24s
kube-system kube-controller-manager-minikube 1/1 Running 0 5m24s
kube-system kube-proxy-g9n8f 1/1 Running 0 5m12s
kube-system kube-scheduler-minikube 1/1 Running 0 5m24s
kube-system storage-provisioner 1/1 Running 1 (4m41s ago) 5m23s
5.安裝ingress-nginx
在 Minikube 環(huán)境中使用 NGINX Ingress 控制器配置 Ingress | Kubernetes
這里就不截圖了,安裝上面地址一步一步執(zhí)行,全部都可以成功。親測(cè)。
6.釋放ECS實(shí)例
不用的時(shí)候可以直接釋放了。資源配置旁邊的點(diǎn)點(diǎn)點(diǎn)。藏的有點(diǎn)深,搜索下“釋放”。文章來源:http://www.zghlxwxcb.cn/news/detail-572929.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-572929.html
到了這里,關(guān)于minikube安裝與運(yùn)行(阿里云環(huán)境運(yùn)行)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!