利用minikube部署kubernetes环境

2022/01/02 CloudNative 共 1945 字,约 6 分钟

准备

准备反向代理,当前为http://127.0.0.1:3129

  1. 可以基于cntlm
  2. 避免下载软件包时被代理拦截

Setup OS

Centos

/etc/profile:

# tail /etc/profile -n 5

export http_proxy=http://127.0.0.1:3129
export https_proxy=http://127.0.0.1:3129
export no_proxy=localhost,127.0.0.1,192.168.0.1/16

# source /etc/profile

配置proxy环境变量

Setup Docker

# mkdir -p /etc/systemd/system/docker.service.d
# vi /etc/systemd/system/docker.service.d/http-proxy.conf
# cat /etc/systemd/system/docker.service.d/http-proxy.conf 
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:3129/"
Environment="HTTPS_PROXY=http://127.0.0.1:3129/"
Environment="NO_PROXY=localhost,127.0.0.0/8,192.168.1.1/16"

# mkdir -p /etc/docker
# vi /etc/docker/daemon.json
# cat /etc/docker/daemon.json 
{
 "registry-mirrors" : [
   "https://mirror.ccs.tencentyun.com",
   "http://docker.mirrors.ustc.edu.cn",
   "http://hub-mirror.c.163.com"
 ],
 "insecure-registries" : [
   "docker.mirrors.ustc.edu.cn"
 ],
 "graph" : "/var/log/docker-graph"
}

配置docker的proxy、registry和graph

# yum install docker -y
# systemctl daemon-reload
# systemctl enable docker
# systemctl restart docker
# docker info

启动docker

Setup Kubernetes

# ls /usr/local/bin/
kubectl  minikube

准备kubectl minikube

# cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward                 = 1
EOF
# sysctl -p /etc/sysctl.d/k8s.conf

# yum install conntrack
# yum install socat

配置依赖

# su - sm
# https_proxy=http://127.0.0.1:3129 minikube start --driver=docker
......
* Using the docker driver based on user configuration
* Starting control plane node minikube in cluster minikube
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Found network options:
  - http_proxy=http://10.182.158.50:3129
! You appear to be using a proxy, but your NO_PROXY environment does not include the minikube IP (192.168.49.2).
......
* Verifying Kubernetes components...
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

启动minikube

Check

# kubectl version --short
Client Version: v1.19.4
Server Version: v1.19.4
# minikube version --short
minikube version: v1.15.1

Search

    Table of Contents