minikube v1.9.2 安装
1、查看当前centos系统版本,并关闭防火墙
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
[root@localhost software]# systemctl stop firewalld
[root@localhost software]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
2、下载安装包并修改权限(没有办法只能墙或者按量付费模式购买海外主机将依赖下载到本地)
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube
3、将minikube安装到path中
sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/
4、查看minikube的版本信息
[root@localhost ~]# minikube version
minikube version: v1.9.2
commit: 93af9c1e43cab9618e301bc9fa720c63d5efa393
[root@localhost ~]#
5、安装docker
  • 卸载旧版docker
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
  • 配置docker仓库地址
$ sudo yum install -y yum-utils

$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
  • 下载对应rpm安装包并本地安装及相关依赖(也是为了安装学习方便将docker安装包rpm通过yumdownloader下载到本地)
[root@localhost software]# yumdownloader --resolve  docker-ce docker-ce-cli containerd.io
[root@localhost software]# ls -l
total 142800
-rw-r--r--. 1 root root 24416076 Mar  2 23:19 containerd.io-1.2.13-3.1.el7.x86_64.rpm
-rw-r--r--. 1 root root 25697324 Mar 11 15:42 docker-ce-19.03.8-3.el7.x86_64.rpm
-rw-r--r--. 1 root root 41468684 Mar 11 15:42 docker-ce-cli-19.03.8-3.el7.x86_64.rpm
-rwxr-xr-x. 1 root root 54639377 Apr 30 09:26 minikube

6、本地安装docker-ce-19.03.8
[root@localhost software]# yum localinstall *.rpm -y  --nogpgcheck
7、离线下载对应kubernetes所需的镜像,下载后tag对应版本
docker tag 43940c34f24f k8s.gcr.io/kube-proxy:v1.18.0     
docker tag a31f78c7c8ce k8s.gcr.io/kube-scheduler:v1.18.0
docker tag d3e55153f52f k8s.gcr.io/kube-controller-manager:v1.18.0   
docker tag 74060cea7f70 k8s.gcr.io/kube-apiserver:v1.18.0
docker tag cdc71b5a8a0e kubernetesui/dashboard:v2.0.0-rc6
docker tag 80d28bedfe5d k8s.gcr.io/pause:3.2
docker tag 67da37a9a360 k8s.gcr.io/coredns:1.6.7
docker tag 303ce5db0e90 k8s.gcr.io/etcd:3.4.3-0
docker tag 3b08661dc379 kubernetesui/metrics-scraper:v1.0.2 
docker tag 4689081edb10 gcr.io/k8s-minikube/storage-provisioner:v1.8.1   
docker tag a90209bb39e3 k8s.gcr.io/echoserver:1.4
8、安装conntrack工具
yum localinstall conntrack-tools-1.4.4-5.el7_7.2.x86_64.rpm -y  --nogpgcheck
  • swap问题处理
[root@localhost ~]# sudo swapoff -a
[root@localhost ~]# systemctl list-units --type=swap --state=active
9、下载kubelet及kubeadm
使用海外机器确认kubernetes最新稳定的版本
[root@iZt4n21lluemt0kwt3ti8oZ software]# curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
v1.18.2
[root@iZt4n21lluemt0kwt3ti8oZ software]# 

下载对应版本工具
wget https://storage.googleapis.com/kubernetes-release/release/v1.18.2/bin/linux/amd64/kubeadm
wget https://storage.googleapis.com/kubernetes-release/release/v1.18.2/bin/linux/amd64/kubelet
wget https://storage.googleapis.com/kubernetes-release/release/v1.18.2/bin/linux/amd64/kubectl

10、可以使用minikube start下载或将已下载文件拷贝到/root/.minikube/cache/linux/v1.18.0
[root@localhost software]# minikube start --driver=none --keep-context=true --download-only=true

下载目录
[root@localhost v1.18.0]# ls -l
total 200896
-rwxr-xr-x. 1 root root 39809024 Apr 30 21:52 kubeadm
-rwxr-xr-x. 1 root root 44023808 Apr 30 21:51 kubectl
-rw-r--r--. 1 root root 52884887 Apr 30 21:53 kubelet
[root@localhost v1.18.0]# pwd
/root/.minikube/cache/linux/v1.18.0
[root@localhost v1.18.0]# 

并同时拷贝到目录/usr/local/bin/下

  • 处理cgroups问题
[root@localhost v1.18.0]# sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
[root@localhost v1.18.0]# 
[root@localhost v1.18.0]# systemctl daemon-reload && systemctl restart kubelet
11、启动minikube
[root@localhost images]# minikube start --driver=none
12、使用minikube
[root@localhost ~]# kubectl get node
NAME                    STATUS   ROLES    AGE   VERSION
localhost.localdomain   Ready    master   57m   v1.18.2
[root@localhost ~]# kubectl get ns
NAME              STATUS   AGE
default           Active   57m
kube-node-lease   Active   57m
kube-public       Active   57m
kube-system       Active   57m
[root@localhost ~]# kubectl get po --all-namespaces
NAMESPACE     NAME                                            READY   STATUS    RESTARTS   AGE
kube-system   coredns-66bff467f8-25v7x                        1/1     Running   1          57m
kube-system   coredns-66bff467f8-qxptg                        1/1     Running   1          57m
kube-system   etcd-localhost.localdomain                      1/1     Running   1          57m
kube-system   kube-apiserver-localhost.localdomain            1/1     Running   1          57m
kube-system   kube-controller-manager-localhost.localdomain   1/1     Running   1          57m
kube-system   kube-proxy-jdmcp                                1/1     Running   1          57m
kube-system   kube-scheduler-localhost.localdomain            1/1     Running   1          57m
kube-system   storage-provisioner                             1/1     Running   2          57m
[root@localhost ~]# 


13、安装minikube ingress
[root@localhost software]# ls
nginx-ingress-controller.tar.gz quay.io+kubernetes-ingress-controller+nginx-ingress-controller:0.26.1.tar
[root@localhost software]# docker load < quay.io+kubernetes-ingress-controller+nginx-ingress-controller\:0.26.1.tar 
69f5d91486f1: Loading layer [==================================================>]  54.01MB/54.01MB
e6f1810f12b9: Loading layer [==================================================>]  26.45MB/26.45MB
23e1268cd811: Loading layer [==================================================>]  1.931MB/1.931MB
fff9425704ad: Loading layer [==================================================>]  296.3MB/296.3MB
3f8f5020e91a: Loading layer [==================================================>]  622.1kB/622.1kB
4a812d06ca7b: Loading layer [==================================================>]  48.83MB/48.83MB
617b955bc962: Loading layer [==================================================>]  9.728kB/9.728kB
82c8c9d646ea: Loading layer [==================================================>]   2.56kB/2.56kB
c51e4b7a59da: Loading layer [==================================================>]  6.144kB/6.144kB
2cea43e70d3a: Loading layer [==================================================>]  36.04MB/36.04MB
177e60f33aba: Loading layer [==================================================>]  23.36MB/23.36MB
30b6afc750c8: Loading layer [==================================================>]  7.168kB/7.168kB
Loaded image ID: sha256:29024c9c6e706357bebda26ea9a15064e77616f4d40c215ce81ae5e4b2a460aa
[root@localhost software]# docker tag 29024c9c6e70 quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.26.1
[root@localhost software]# minikube addons enable ingress
* The 'ingress' addon is enabled
[root@localhost software]# 
14、使用minikube dashboard查看可视化界面
  • 将为dashboard添加外部访问代理
minikube addons list 查看
minikube addons enable dashboard
minikube addons disable dashboard

暴露端口方式
kubectl proxy --port=8080 --address='192.168.2.4' --accept-hosts='^.*' &


  • 通过以下地址访问
http://192.168.2.4:8080/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview?namespace=default
15、部署postwoman
[root@localhost software]# tar -xzvf postwoman.tar.gz 
liyasthomas+postwoman:latest.tar
[root@localhost software]# docker load < liyasthomas+postwoman:latest.tar
f1b5933fe4b5: Loading layer [==================================================>]  5.796MB/5.796MB
1a86ff1d449f: Loading layer [==================================================>]  73.31MB/73.31MB
7dcca1b6d2c7: Loading layer [==================================================>]   5.53MB/5.53MB
414e34102ae8: Loading layer [==================================================>]  3.584kB/3.584kB
640e637fb132: Loading layer [==================================================>]  15.37MB/15.37MB
c977c8de906a: Loading layer [==================================================>]  1.536kB/1.536kB
53e3dde40ea6: Loading layer [==================================================>]  673.3kB/673.3kB
68314fa047c6: Loading layer [==================================================>]    875MB/875MB
a108fd9771a9: Loading layer [==================================================>]  14.04MB/14.04MB
5b4f5f7d83a2: Loading layer [==================================================>]  37.71MB/37.71MB
Loaded image ID: sha256:dcc692ed621e273020c7766ce2c67b98e3dfe039f3b93a03db3512ebac0f192a
[root@localhost software]# 
[root@localhost software]# docker tag dcc692ed621e liyasthomas/postwoman:latest
[root@localhost software]# 
  • postwoman.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postwoman
spec:
  selector:
    matchLabels:
      app: postwoman
  replicas: 2
  template:
    metadata:
      labels:
        app: postwoman
    spec:
      containers:
      - name: postwoman
        image: liyasthomas/postwoman:latest
        ports:
        - containerPort: 80
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postwoman
spec:
  selector:
    matchLabels:
      app: postwoman
  replicas: 2
  template:
    metadata:
      labels:
        app: postwoman
    spec:
      containers:
      - name: postwoman
        image: liyasthomas/postwoman:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: postwoman
  namespace: default
spec:
  selector:
    app: postwoman
  ports:
  - name: http
    targetPort: 3000
    port: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-postwoman
  namespace: default
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: postwoman.ioe.com
    http:
      paths:
      - path:
        backend:
          serviceName: postwoman
          servicePort: 80

赞赏(Donation)
微信(Wechat Pay)

donation-wechatpay