博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
手动安装K8s第九节:创建dashboard和发布应用
阅读量:6552 次
发布时间:2019-06-24

本文共 7389 字,大约阅读时间需要 24 分钟。

创建CoreDNS

[root@k8smaster coredns]# ls
coredns.yaml
[root@k8smaster coredns]# kubectl create -f .
serviceaccount "coredns" created
clusterrole.rbac.authorization.k8s.io "system:coredns" created
clusterrolebinding.rbac.authorization.k8s.io "system:coredns" created
configmap "coredns" created
deployment.extensions "coredns" created
service "coredns" created

创建Dashboard

[root@k8smaster addons]# cd dashboard/
[root@k8smaster dashboard]# ls
admin-user-sa-rbac.yaml kubernetes-dashboard.yaml ui-admin-rbac.yaml ui-read-rbac.yaml
[root@k8smaster dashboard]# kubectl create -f .
serviceaccount "admin-user" created
clusterrolebinding.rbac.authorization.k8s.io "admin-user" created
secret "kubernetes-dashboard-certs" created
serviceaccount "kubernetes-dashboard" created
role.rbac.authorization.k8s.io "kubernetes-dashboard-minimal" created
rolebinding.rbac.authorization.k8s.io "kubernetes-dashboard-minimal" created
deployment.apps "kubernetes-dashboard" created
service "kubernetes-dashboard" created
clusterrole.rbac.authorization.k8s.io "ui-admin" created
rolebinding.rbac.authorization.k8s.io "ui-admin-binding" created
clusterrole.rbac.authorization.k8s.io "ui-read" created
rolebinding.rbac.authorization.k8s.io "ui-read-binding" created

[root@k8smaster dashboard]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Name: admin-user-token-hxlzj
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name=admin-user
kubernetes.io/service-account.uid=515020bb-6ec5-11e8-bf01-000c29007455

Type: kubernetes.io/service-account-token

Data

ca.crt: 1359 bytes

namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLWh4bHpqIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI1MTUwMjBiYi02ZWM1LTExZTgtYmYwMS0wMDBjMjkwMDc0NTUiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.lqSmY5ZKhJ_s7czQs8Mif-a6pkSPU3OC3UzobE095HYlm3fn_l66bEIBV9-7BXdl9vyWch1g8Aryr0zyFrhjJxhK9t7eEzmLHP3qm3BjyTa4LlrKXxffkXpXiOSSlYxx4ZuExKO7rvvEtwEQUoru1eOGVRPJQwCfSMZsNQp27bBa6ocMgYJqOSqgd8iR76vq8RYKmOVGQRDbY_iVGZb_VGcFFGZexx8miPlgbk3zHjx9ENivIU9K9huoUsx505cpsCQWc-wz7_DTfKeOedmxh3e1ebUzDo9ww1pd-05sgN0GovuAEXtpoanGEVBaFPGoB3wb3b6ilyxY3FDHzFrTLA

查看状态

[root@k8smaster dashboard]# kubectl get pods -o wide -n kube-system
NAME READY STATUS RESTARTS AGE IP NODE
coredns-77c989547b-4dfnn 1/1 Running 5 11m 10.2.59.3 k8snode2
coredns-77c989547b-54s8d 1/1 Running 6 11m 10.2.57.3 k8snode1
kubernetes-dashboard-66c9d98865-txvx2 1/1 Running 2 1m 10.2.57.4 k8snode1

[root@k8smaster dashboard]# kubectl get services -o wide -n kube-system

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
coredns ClusterIP 10.1.0.2 <none> 53/UDP,53/TCP 12m k8s-app=coredns
kubernetes-dashboard ClusterIP 10.1.72.67 <none> 443/TCP 10m k8s-app=kubernetes-dashboard
[root@k8smaster dashboard]# kubectl cluster-info
Kubernetes master is running at
CoreDNS is running at
kubernetes-dashboard is running at

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

[root@k8smaster ~]# kubectl cluster-info

Kubernetes master is running at
CoreDNS is running at
kubernetes-dashboard is running at

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

[root@k8smaster ~]# kubectl get services -o wide -n kube-system

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
coredns ClusterIP 10.1.0.2 <none> 53/UDP,53/TCP 19m k8s-app=coredns
kubernetes-dashboard ClusterIP 10.1.150.142 <none> 443/TCP 9m k8s-app=kubernetes-dashboard
[root@k8smaster ~]#
[root@k8smaster ~]# kubectl get pods -o wide -n kube-system
NAME READY STATUS RESTARTS AGE IP NODE
coredns-77c989547b-8tbcs 1/1 Running 0 7m 10.2.59.7 192.168.137.198
coredns-77c989547b-gzz2g 1/1 Running 0 7m 10.2.36.6 192.168.137.201
kubernetes-dashboard-66c9d98865-fk2lb 1/1 Running 0 8m 10.2.36.5 192.168.137.201

手动安装K8s第九节:创建dashboard和发布应用

2

手动安装K8s第九节:创建dashboard和发布应用

3

手动安装K8s第九节:创建dashboard和发布应用

1、创建应用一:

[root@k8smaster ~]# kubectl run net-test --image=alpine --replicas=2 sleep 360000
deployment.apps "net-test" created
[root@k8smaster ~]#
[root@k8smaster ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
net-test-5767cb94df-v8w6n 0/1 ContainerCreating 0 38s
net-test-5767cb94df-z5xgm 0/1 ContainerCreating 0 37s
[root@k8smaster ~]#
[root@k8smaster ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
net-test-5767cb94df-v8w6n 1/1 Running 0 2m
net-test-5767cb94df-z5xgm 1/1 Running 0 2m
[root@k8smaster ~]#
[root@k8smaster ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
net-test-5767cb94df-v8w6n 1/1 Running 0 2m 10.2.59.2 k8snode2
net-test-5767cb94df-z5xgm 1/1 Running 0 2m 10.2.57.2 k8snode1
[root@k8smaster ~]# ping 10.2.59.2 -c 4
PING 10.2.59.2 (10.2.59.2) 56(84) bytes of data.
64 bytes from 10.2.59.2: icmp_seq=1 ttl=63 time=1.01 ms
64 bytes from 10.2.59.2: icmp_seq=2 ttl=63 time=0.647 ms
64 bytes from 10.2.59.2: icmp_seq=3 ttl=63 time=1.34 ms
64 bytes from 10.2.59.2: icmp_seq=4 ttl=63 time=0.702 ms

--- 10.2.59.2 ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.647/0.925/1.342/0.278 ms
[root@k8smaster ~]# ping 10.2.57.2 -c 4
PING 10.2.57.2 (10.2.57.2) 56(84) bytes of data.
64 bytes from 10.2.57.2: icmp_seq=1 ttl=63 time=1.92 ms
64 bytes from 10.2.57.2: icmp_seq=2 ttl=63 time=0.415 ms
64 bytes from 10.2.57.2: icmp_seq=3 ttl=63 time=0.453 ms
64 bytes from 10.2.57.2: icmp_seq=4 ttl=63 time=0.483 ms

--- 10.2.57.2 ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.415/0.820/1.929/0.640 ms

2、创建Nginx

[root@k8smaster ~]# kubectl run nginx --image=nginx --replicas=2
deployment.apps "nginx" created

[root@k8smaster ~]# kubectl expose deployment nginx --type=NodePort --name=nginx --port=80

service "nginx" exposed

[root@k8smaster ~]# kubectl get services -o wide

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.1.0.1 <none> 443/TCP 7h <none>
nginx NodePort 10.1.133.181 <none> 80:32109/TCP 6s run=nginx
[root@k8smaster ~]#
[root@k8smaster ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx-65899c769f-nwxw4 1/1 Running 0 4m 10.2.59.6 192.168.137.198
nginx-65899c769f-sxq7m 1/1 Running 0 4m 10.2.36.3 192.168.137.201

手动安装K8s第九节:创建dashboard和发布应用

Nginx访问成功!

[root@k8snode1 ~]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.137.201:32109 rr
-> 10.2.36.3:80 Masq 1 1 0
-> 10.2.59.6:80 Masq 1 1 0
TCP 192.168.137.215:32109 rr
-> 10.2.36.3:80 Masq 1 0 0
-> 10.2.59.6:80 Masq 1 0 0
TCP 10.1.0.1:443 rr persistent 10800
-> 192.168.137.171:6443 Masq 1 0 0
TCP 10.1.0.2:53 rr
-> 10.2.59.4:53 Masq 1 0 0
TCP 10.1.72.67:443 rr
TCP 10.1.133.181:80 rr
-> 10.2.36.3:80 Masq 1 0 0
-> 10.2.59.6:80 Masq 1 0 0
TCP 10.2.36.0:32109 rr
-> 10.2.36.3:80 Masq 1 0 0
-> 10.2.59.6:80 Masq 1 0 0
TCP 10.2.36.1:32109 rr
-> 10.2.36.3:80 Masq 1 0 0
-> 10.2.59.6:80 Masq 1 0 0
TCP 127.0.0.1:32109 rr
-> 10.2.36.3:80 Masq 1 0 0
-> 10.2.59.6:80 Masq 1 0 0
UDP 10.1.0.2:53 rr
-> 10.2.59.4:53 Masq 1 0 0

转载于:https://blog.51cto.com/andyliu/2129078

你可能感兴趣的文章
我常用的命令
查看>>
tengine+tomcat+php安装
查看>>
第 45 章 HyperDex
查看>>
会议室预定系统实践(轻松解放开发) - PostgreSQL tsrange(时间范围类型) + 排他约束...
查看>>
Centos6安装SaltStack
查看>>
世纪互联发布全新云战略,打造混合IT服务平台
查看>>
关于在angular2及以上版本引入bootstrap 并有提示功能
查看>>
十三、rsync+inotify的使用
查看>>
浅说RAID和LVM
查看>>
Spring Cloud微服务分布式云架构-集成项目
查看>>
namenode与secondary namenode简要学习
查看>>
软件测试人员的进击
查看>>
10.26 unit介绍
查看>>
开源博客markdown插入表格语法
查看>>
Linux监控平台介绍,zabbix监控介绍,安装zabbix,忘记Admin密码如何做
查看>>
公众号消息会话开发
查看>>
The method xx方法( ) is undefined for the type XX类
查看>>
接口请求的本地缓存策略
查看>>
后端开发 腾讯一面的失败经历
查看>>
Hadoop简介
查看>>