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 @ 2024-01-03 18:36  小不点丶  阅读(23)  评论(0编辑  收藏  举报