k3s应用

  一、测试实例

复制代码
apiVersion: v1
kind: Namespace
metadata:
  name: xbd
---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: xbd
  name: xbd-demo-server
spec:
  selector:
    matchLabels:
      run: xbd-demo-server
  template:
    metadata:
      labels:
        run: xbd-demo-server
    spec:
      containers:
        - name: xbd-demo-server
          image: nginx:1.23.4-alpine
          ports:
            - containerPort: 80
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  namespace: xbd
  name: xbd-demo
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  selector:
    run: xbd-demo-server
  type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: xbd
  name: xbd-demo-ingress
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: websecure
spec:
  ingressClassName: traefik
  rules:
    - host: xbd.demo.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: xbd-demo
                port:
                  number: 80
View Code
复制代码

  说明:在k3s中默认使用traefik来作为Ingress Controller使用。

  执行命令:

kubectl apply -f demo.yml

  注解说明:

  annotations:
     traefik.ingress.kubernetes.io/router.entrypoints: websecure
  web:http
  
websecure:https
  配置hosts
192.168.5.200/201 xbd.demo.com

  测试

  

  二、crictl本地镜像导入

ctr -n k8s.io images import <image.tar>

  备注:遇到坑,我的机器是装了docker相关的,一直导致离线包导入失败,需要注意!

   三、kuboard

复制代码
apiVersion: v1
kind: Namespace
metadata:
  name: kuboard
---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: kuboard
  name: kuboard
spec:
  selector:
    matchLabels:
      run: kuboard
  template:
    metadata:
      labels:
        run: kuboard
    spec:
      containers:
        - name: kuboard
          image: eipwork/kuboard:v3.5.2.6
          env:
            - name: TZ
              value: 'Asia/Shanghai'
            - name: KUBOARD_ENDPOINT
              value: 'http://xbd.kuboard.com'
          ports:
            - containerPort: 80
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  namespace: kuboard
  name: kuboard
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  selector:
    run: kuboard
  type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: kuboard
  name: kuboard
spec:
  rules:
    - host: xbd.kuboard.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: kuboard
                port:
                  number: 80
View Code
复制代码

 

 

 

 
posted @   小不点丶  阅读(28)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 我干了两个月的大项目,开源了!
· 推荐一款非常好用的在线 SSH 管理工具
· 千万级的大表,如何做性能调优?
· 聊一聊 操作系统蓝屏 c0000102 的故障分析
· .NET周刊【1月第1期 2025-01-05】
点击右上角即可分享
微信分享提示