一、 初始化
systemctl stop firewalld && systemctl disable firewalld
swapoff -a
setenforce 0
cat <<EOF > etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
setenforce 0复制
二、下载安装 minikube
1、下载minikube (建议使用阿里云镜像,国外镜像太慢了)
curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.3.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube usr/local/bin/
复制
或者手动获取代码了
git clone https://github.com/AliyunContainerService/minikube
cd minikube
git checkout aliyun-v1.3.1
make
sudo cp out/minikube usr/local/bin/复制
2、帮助文档
[root@xuxingyue-test-01 ~]# minikube --help
Minikube is a CLI tool that provisions and manages single-node Kubernetes clusters optimized for development workflows.
Basic Commands:
start Starts a local kubernetes cluster
status Gets the status of a local kubernetes cluster
stop Stops a running local kubernetes cluster
delete Deletes a local kubernetes cluster
dashboard Access the kubernetes dashboard running within the minikube cluster
Images Commands:
docker-env Sets up docker env variables; similar to '$(docker-machine env)'
cache Add or delete an image from the local cache.
Configuration and Management Commands:
addons Modify minikube's kubernetes addons
config Modify minikube config
profile Profile gets or sets the current minikube profile
update-context Verify the IP address of the running cluster in kubeconfig.
Networking and Connectivity Commands:
service Gets the kubernetes URL(s) for the specified service in your local cluster
tunnel tunnel makes services of type LoadBalancer accessible on localhost
Advanced Commands:
mount Mounts the specified directory into minikube
ssh Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'
kubectl Run kubectl
Troubleshooting Commands:
ssh-key Retrieve the ssh identity key path of the specified cluster
ip Retrieves the IP address of the running cluster
logs Gets the logs of the running instance, used for debugging minikube, not user code.
update-check Print current and latest version number
version Print the version of minikube
Other Commands:
completion Outputs minikube shell completion for the given shell (bash or zsh)
Use "minikube <command> --help" for more information about a given command.复制
正式安装 安装有2种方式,一、是提前安装VirtualBox,二、添加一个"--vm-driver=none",目前这里安装采用第二种
[root@test-01 ~]# minikube start --vm-driver=none --registry-mirror=https://docker.mirrors.ustc.edu.cn
* minikube v1.3.1 on Centos 7.6.1810
* Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers
* Running on localhost (CPUs=4, Memory=3789MB, Disk=25587MB) ...
* OS release is CentOS Linux 7 (Core)
* Preparing Kubernetes v1.15.2 on Docker 19.03.0 ...
* Downloading kubeadm v1.15.2
* Downloading kubelet v1.15.2
* 拉取镜像 ...
* 正在启动 Kubernetes ...
* Configuring local host environment ...
*
! The 'none' driver provides limited isolation and may reduce system security and reliability.
! For more information, see:
- https://minikube.sigs.k8s.io/docs/reference/drivers/none/
*
! kubectl and minikube configuration will be stored in root
! To use kubectl or minikube commands as your own user, you may
! need to relocate them. For example, to overwrite your own settings:
*
- sudo mv /root/.kube /root/.minikube $HOME
- sudo chown -R $USER $HOME/.kube $HOME/.minikube
*
* This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true复制
三、测试容器案例并访问
1、启动一个容器
[root@test-01 ~]# kubectl run kube-nginx --image=nginx:latest --port=80
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
修改为如下命令
[root@test-01 ~]# kubectl run --generator=run-pod/v1 kube-nginx --image=nginx:latest --port=80
pod/kube-nginx created复制
2、查看状态
[root@test-01 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
kube-nginx-7c765ffd95-rszh4 1/1 Running 0 20m复制
3、查看集群信息
[root@test-01 ~]# kubectl cluster-info
Kubernetes master is running at https://10.10.40.5:8443
KubeDNS is running at https://10.10.40.5:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.复制
4、查看启动日志
[root@test-01 ~]# minikube logs
* ==> Docker <==
* -- Logs begin at 四 2019-08-29 11:28:07 CST, end at 四 2019-08-29 15:10:53 CST. --
* 8月 29 13:43:19 test-01 dockerd[19819]: time="2019-08-29T13:43:19.670690663+08:00" level=info msg="Attempting next endpoint for pull after error: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
* 8月 29 13:43:19 test-01 dockerd[19819]: time="2019-08-29T13:43:19.670742179+08:00" level=error msg="Handler for POST v1.40/images/create returned error: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"复制
5、重新启动服务
[root@test-01 ~]# kubectl run kube-nginx --image=nginx:latest --port=80 --image-pull-policy=IfNotPresent
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
Error from server (AlreadyExists): deployments.apps "kube-nginx" already exists复制
6、发布服务
[root@test-01 ~]# kubectl expose deployment kube-nginx --type=NodePort
service/kube-nginx exposed复制
7、取得deployments列表
[root@test-01 ~]# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
kube-nginx 1/1 1 1 13m复制
8、查看服务地址
[root@test-01 ~]# minikube service kube-nginx --url
* http://10.10.40.5:30017复制
9、访问地址:http://10.10.40.5:30017
四、minikube 安装dashboard
dashboard管理后台是kubernetes提供的容器管理后台,可以用来进行机器负载,集群管理,镜像扩展,配置参数等相关操作
1、直接通过minikube dashboard
[root@xuxingyue-test-01 ~]# minikube dashboard --url
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:5154/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/复制
2、命令安装dashboard
[root@test-01 ~]# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta1/aio/deploy/recommended.yaml
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/kubernetes-metrics-scraper created复制
[root@test-01 ~]# kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'
Starting to serve on [::]:8001复制
3、访问URL :http://10.10.40.5:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/
爱运维^_^爱分享
文章转载自Linux运维技术之路,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
数据库国产化替代深化:DBA的机遇与挑战
代晓磊
1206次阅读
2025-04-27 16:53:22
2025年4月国产数据库中标情况一览:4个千万元级项目,GaussDB与OceanBase大放异彩!
通讯员
687次阅读
2025-04-30 15:24:06
数据库,没有关税却有壁垒
多明戈教你玩狼人杀
586次阅读
2025-04-11 09:38:42
国产数据库需要扩大场景覆盖面才能在竞争中更有优势
白鳝的洞穴
567次阅读
2025-04-14 09:40:20
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
491次阅读
2025-04-17 17:02:24
一页概览:Oracle GoldenGate
甲骨文云技术
468次阅读
2025-04-30 12:17:56
GoldenDB数据库v7.2焕新发布,助力全行业数据库平滑替代
GoldenDB分布式数据库
459次阅读
2025-04-30 12:17:50
优炫数据库成功入围新疆维吾尔自治区行政事业单位数据库2025年框架协议采购!
优炫软件
353次阅读
2025-04-18 10:01:22
国产数据库图谱又上新|82篇精选内容全览达梦数据库
墨天轮编辑部
266次阅读
2025-04-23 12:04:21
关于征集数据库标准体系更新意见和数据库标准化需求的通知
数据库标准工作组
239次阅读
2025-04-11 11:30:08