码迷,mamicode.com
首页 > 其他好文 > 详细

Kind---也很方便的微型k8s实验环境

时间:2020-03-28 13:49:04      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:googl   命令行   gis   mil   please   beta   conf   web   path   

k3s弄好之后,发现使用client-go时,不是很方便,老是提示证书验证书127.0.0.1才可以,其它的IP都有问题。

我是要在k8s上跑二次开发的,就不再细细研究,然后,再考察kind方案吧。

这个kind只依赖于一个docker镜像,感觉还可以接受,关键是,我的websocket可以在这上面跑起来呢。

大约步骤如下:

一,获取kind命令。

go get -u sigs.k8s.io/kind

 

二,先获取好指定镜像,胜于漫长的命令行等待。

docker pull kindest/node:v1.17.0

 

三,生成基于国内镜像源的kind-config.yaml文件

kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
kubeadmConfigPatches:
- |
  apiVersion: kubeadm.k8s.io/v1beta1
  kind: ClusterConfiguration
  metadata:
    name: config
  networking:
    serviceSubnet: 10.0.0.0/16
  imageRepository: registry.aliyuncs.com/google_containers
  nodeRegistration:
    kubeletExtraArgs:
      pod-infra-container-image: registry.aliyuncs.com/google_containers/pause:3.1
- |
  apiVersion: kubeadm.k8s.io/v1beta1
  kind: InitConfiguration
  metadata:
    name: config
  networking:
    serviceSubnet: 10.0.0.0/16
  imageRepository: registry.aliyuncs.com/google_containers
nodes:
- role: control-plane

 

四,安装指定name的k8s集群

kind create cluster --name aguncn --config kind-config.yaml

 

五,半支烟的功夫,看输出(要没有Kubectl命令,自己从网上找一个)

kubectl get pod -A
NAMESPACE            NAME                                           READY   STATUS    RESTARTS   AGE
default              nginx-549f84596b-jmkhf                         1/1     Running   0          107m
kube-system          coredns-6955765f44-jkn2x                       1/1     Running   0          110m
kube-system          coredns-6955765f44-xb4hm                       1/1     Running   0          110m
kube-system          etcd-aguncn-control-plane                      1/1     Running   0          110m
kube-system          kindnet-ffv8n                                  1/1     Running   0          110m
kube-system          kube-apiserver-aguncn-control-plane            1/1     Running   0          110m
kube-system          kube-controller-manager-aguncn-control-plane   1/1     Running   0          110m
kube-system          kube-proxy-nk2rm                               1/1     Running   0          110m
kube-system          kube-scheduler-aguncn-control-plane            1/1     Running   0          110m
local-path-storage   local-path-provisioner-7745554f7f-b62wg        1/1     Running   0          110m

 

技术图片

六,为了测试一个简单的Nginx,使用kind load命令,先将本地镜像的nginx导入kind中。

kind load docker-image --name aguncn  nginx:1.16-alpine

 

七,弄一个简单的yaml启动

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      name: nginx
  template:
    metadata:
      labels:
        name: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.16-alpine
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service-nodeport
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: NodePort
  selector:
    name: nginx

 

八,本地应该可以访问了

curl http://172.17.2:32622
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

 

九,安装一个rinetd作代理

https://www.jianshu.com/p/2605d247b944

https://www.cnblogs.com/Paul-watermelon/p/10365924.html

0.0.0.0 8080 172.17.2 32622

 

十,跨越主机访问,搞定。

技术图片

 

Kind---也很方便的微型k8s实验环境

标签:googl   命令行   gis   mil   please   beta   conf   web   path   

原文地址:https://www.cnblogs.com/aguncn/p/12586806.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!