使用Kubernetes快速启用一个静态页面

使用Kubernetes快速启用一个静态页面

将html静态页面放置在nfs目录下,通过Deployment启动时挂在到nginx页面目录即可

查看yaml内容

root@hello:~# cat cby.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chenby
spec:
  replicas: 3
  selector:
    matchLabels:
      app: chenby
  template:
    metadata:
      labels:
        app: chenby
    spec:
      containers:
      - name: chenby
        image: nginx
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 80
        volumeMounts:
        - name: cby-nfs
          mountPath: /usr/share/nginx/html/
      volumes:
      - name: cby-nfs
        nfs:
          server: 192.168.1.123
          path: /cby-3/nfs/html

---
apiVersion: v1
kind: Service
metadata:
  name: chenby
spec:
  type: NodePort
  selector:
    app: chenby
  ports:
  - port: 80
    targetPort: 80

查看验证

root@hello:~# kubectl  get deployments.apps  chenby  -o wide
NAME     READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS   IMAGES   SELECTOR
chenby   3/3     3            3           4m44s   chenby       nginx    app=chenby
root@hello:~# 


root@hello:~# kubectl  get pod -o wide | grep chenby
chenby-77b57649c7-qv2ps                  1/1     Running   0          5m2s   172.17.125.19    k8s-node01     <none>           <none>
chenby-77b57649c7-rx98c                  1/1     Running   0          5m2s   172.25.214.207   k8s-node03     <none>           <none>
chenby-77b57649c7-tx2dz                  1/1     Running   0          5m2s   172.25.244.209   k8s-master01   <none>           <none>



root@hello:~# kubectl  get svc -o wide | grep chenby
chenby                NodePort    10.109.222.0    <none>        80:30971/TCP   5m8s   app=chenby
root@hello:~#

演示

b968233122e70fb246e1b8bcefaae304.png

在线体验:

https://www.oiox.cn/

https://www.chenby.cn/

https://blog.oiox.cn/

https://www.oiox.cn/

https://www.chenby.cn/

https://blog.oiox.cn/

https://cby-chen.github.io/

https://blog.csdn.net/qq_33921750

https://my.oschina.net/u/3981543

https://www.zhihu.com/people/chen-bu-yun-2

https://segmentfault.com/u/hppyvyv6/articles

https://juejin.cn/user/3315782802482007

https://cloud.tencent.com/developer/column/93230

https://www.jianshu.com/u/0f894314ae2c

https://www.toutiao.com/c/user/token/MS4wLjABAAAAeqOrhjsoRZSj7iBJbjLJyMwYT5D0mLOgCoo4pEmpr4A/

CSDN、GitHub、知乎、开源中国、思否、掘金、简书、腾讯云、今日头条、个人博客、全网可搜《小陈运维》

文章主要发布于微信公众号:《Linux运维交流社区》

posted @   小陈运维  阅读(11)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
点击右上角即可分享
微信分享提示