本文主要是介绍飞天使-k8s知识点4-验证安装好后功能,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 接k8s知识点2之验证集群功能
- 创建dashboard
- 验证安装nginx 并访问
- tomcat 访问
接k8s知识点2之验证集群功能
[root@kubeadm-master2 tmp]# kubectl run net-test1 --image=alpine sleep 36000
pod/net-test1 created
[root@kubeadm-master2 tmp]# kubectl get pod
NAME READY STATUS RESTARTS AGE
net-test1 1/1 Running 0 9s
[root@kubeadm-master2 tmp]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
net-test1 1/1 Running 0 23s 10.100.3.2 ha1.example.local <none> <none>
创建dashboard
https://github.com/kubernetes/dashboard
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml
mv recommended.yaml dashboard-2.2.4.yaml[root@kubeadm-master1 m43]# kubectl apply -f dashboard-2.2.0_m43.yaml -f admin-user.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/dashboard-metrics-scraper created
serviceaccount/admin-user created
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
[root@kubeadm-master1 m43]# kubectl get svc -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.200.158.176 <none> 8000/TCP 9s
kubernetes-dashboard NodePort 10.200.215.254 <none> 443:32002/TCP 10s[root@kubeadm-master1 m43]# kubectl get secret -A | grep admin
kubernetes-dashboard admin-user-token-49f94 kubernetes.io/service-account-token 3 19m
[root@kubeadm-master1 m43]# kubectl describe secret admin-user-token-49f94 -n kubernetes-dashboard
Name: admin-user-token-49f94
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: admin-userkubernetes.io/service-account.uid: a03e2d07-6341-4982-867f-5b44c06c263bType: kubernetes.io/service-account-tokenData
====
ca.crt: 1066 bytes
namespace: 20 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6Inl5bjFBQ2FTMWs5dUUxUHFnVnhqMmFHSE01Um5FVjNMcjRxS3NpQUJ2bmcifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLTQ5Zjk0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJhMDNlMmQwNy02MzQxLTQ5ODItODY3Zi01YjQ0YzA2YzI2M2IiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.MlfYzXvCkmxx2wxpPPh32dAPyHilg3hdacHBN8iueu6H6jQtn0Ilezw3u4_2QXzgH68xcqmL4O8dOo68DkwXmh_37oEFD9tFAdhEilygxkcPo7lSOuQxu9dk9W79cPxFmnn8AMvYFyIXgBOsyw9NcF9w77q8cecqSxN8qQH0K9uf4N52iO6MkbCQ-t2gwpljWXHg3BREk
验证安装nginx 并访问
apiVersion: apps/v1
kind: Deployment
metadata:namespace: defaultname: nginx-deploymentlabels:app: nginx
spec:replicas: 1selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:1.18.0ports:- containerPort: 80---
kind: Service
apiVersion: v1
metadata:labels:app: test-nginx-service-labelname: test-nginx-servicenamespace: default
spec:type: NodePortports:- name: httpport: 80protocol: TCPtargetPort: 80nodePort: 30004selector:app: nginx
tomcat 访问
apiVersion: apps/v1
kind: Deployment
metadata:namespace: defaultname: tomcat-deploymentlabels:app: tomcat
spec:replicas: 1selector:matchLabels:app: tomcattemplate:metadata:labels:app: tomcatspec:containers:- name: tomcatimage: tomcatports:- containerPort: 8080---
kind: Service
apiVersion: v1
metadata:labels:app: test-tomcat-service-labelname: test-tomcat-servicenamespace: default
spec:type: NodePortports:- name: httpport: 80protocol: TCPtargetPort: 8080nodePort: 30005selector:app: tomcat
这篇关于飞天使-k8s知识点4-验证安装好后功能的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!