Kubernetes 创建测试用 Deployment Service Pod

Kubernetes kubectl About 1,006 words

yaml

apiVersion: apps/v1
kind: Deployment      
metadata:
  name: nginx-deployment
  namespace: my-ns
spec: 
  replicas: 1
  selector:
    matchLabels:
      app: nginx-pod
  template:
    metadata:
      labels:
        app: nginx-pod
    spec:
      containers:
      - name: nginx
        image: nginx:1.25.3-alpine
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: my-ns
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: nginx-pod

创建

kubectl --kubeconfig /root/dev.yaml create -f /root/k8s-nginx.yaml

删除

kubectl --kubeconfig /root/dev.yaml delete -f /root/k8s-nginx.yaml

Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
  namespace: my-ns
spec:
  rules:
    - host: www.example.com
      http:
        paths:
          - path: /my
            pathType: Prefix
            backend:
              service:
                name: nginx-service
                port:
                  number: 80
Views: 458 · Posted: 2024-08-06

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh