k8s配置檔案

shiningrise發表於2024-10-10
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: web
  name: web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: web
    spec:
      containers:
      - image: registry.cn-hangzhou.aliyuncs.com/shiningrise/nginx:1.22.1
        name: nginx
        resources: {}
status: {}

---
apiVersion: v1
kind: Service
metadata:
  name: my-nodeport-service
  labels:
    app: web
spec:
  type: NodePort
  selector:
    app: web
  ports:
  - name: http
    port: 80
    targetPort: 80
    nodePort: 30001  # 可選,如果沒有指定,Kubernetes 會自動分配