侧边栏壁纸
  • 累计撰写 23 篇文章
  • 累计创建 7 个标签
  • 累计收到 0 条评论
标签搜索

目 录CONTENT

文章目录

k8s运维(八)部署测试应用

爱喝酸梅汤的小猫咪
2023-05-30 / 0 评论 / 0 点赞 / 504 阅读 / 408 字

一、测试nginx

1.创建web-nginx.yaml 文件

apiVersion: apps/v1
kind: Deployment
metadata:
 name: web-nginx
 namespace: default
spec:
 replicas: 3
 selector:
   matchLabels:
     type: web
 template:
   metadata:
     labels:
       type: web
   spec:
     containers:
     - name: web-nginx
       image: nginx:alpine
---
apiVersion: v1
kind: Service
metadata:
 name: web-nginx-entrypoint
 namespace: default
spec:
 type: NodePort
 selector:
   type: web
 ports:
 - port: 80
   targetPort: 80
   nodePort: 30001

2.执行

$ kubectl apply -f web-nginx.yaml
deployment.apps/web-nginx created
service/web-nginx-entrypoint created

查看:
$ kubectl get pods -A | grep web-nginx
default        web-nginx-8849754ff-cl567             1/1     Running   0          83s
default        web-nginx-8849754ff-ftwvf             1/1     Running   0          83s
default        web-nginx-8849754ff-r8xzk             1/1     Running   0          83s

3.访问

浏览器访问,都可以访问通
http://10.211.55.20:30001/
http://10.211.55.21:30001/
http://10.211.55.22:30001/

4.删除nginx

$ kubectl delete -f web-nginx.yaml

二、安装metrics-server

16711586480985

1.安装

下载文件
$ wget https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.1/components.yaml

修改文件
 - --cert-dir=/tmp
 - --secure-port=4443
 - --kubelet-insecure-tls
 - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
添加了 - --kubelet-insecure-tls

拉去镜像
$ docker pull registry.aliyuncs.com/google_containers/metrics-server:v0.6.1
修改tag
$ docker tag registry.aliyuncs.com/google_containers/metrics-server:v0.6.1 k8s.gcr.io/metrics-server/metrics-server:v0.6.1
$ docker rmi -f registry.aliyuncs.com/google_containers/metrics-server:v0.6.1

注意:是给所以机器都安上该镜像

安装
$ kubectl apply -f components.yaml

16711966146402

2.使用

16711976416478

3.卸载

$ kubectl delete -f components.yaml
并删除镜像

三、安装Kuboard V3

1.安装

$ kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
查看状态
$ watch kubectl get pods -o wide -n kuboard 


16711177523152

打开地址
http://10.211.55.20:30080/
用户名:admin
密码:Kuboard123

查看一下nginx

16711184217221

可看到很多功能,很不错

2.卸载

$ kubectl delete -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
清除数据
$ rm -rf /usr/share/kuboard
0
  • 0

评论区