2

在此处输入图像描述

我正在研究 Canary 部署策略。安装trafik 网格后,我使用服务网格接口。第一次使用命令启动程序时

kubectl apply -f applications.yaml

它应该部署整个应用程序,即 4 个副本,但它只部署了应用程序的 20%(1 个副本),并且它进入了进度状态并出现错误:

TrafficRoutingErro: the server could not find the requested resource (post trafficsplits.splits.smi-spec.io) TrafficSplitNotCreated: Unable to create traffic Split 'demo-traefficsplit'

这是我的清单:

argocd-rollout.yaml

---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: demo
  labels:
    app: demo
spec:
  strategy:
    canary:
      steps:
      - setWeight: 20
      - pause:
          duration: "1m"
      - setWeight: 50
      - pause:
          duration: "2m"
      canaryService: demo-canary
      stableService: demo

      trafficRouting:
        smi:
          rootService: demo-smi
          trafficSplitName: demo-trafficsplit

  replicas: 4
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: demo
      version: blue
  template:
    metadata:
      labels:
        app: demo
        version: blue
    spec:
      containers:
      - name: demo
        image: argoproj/rollouts-demo:blue
        imagePullPolicy: Always
        ports:
        - name: web
          containerPort: 8080
        resources:
          requests:
            memory: "64Mi"
            cpu: "100m"
          limits:
            memory: "128Mi"
            cpu: "140m"

---
apiVersion: split.smi-spec.io/v1alpha3
kind: TrafficSplit
metadata:
  name: demo-trafficsplit
spec:
  service: demo-smi # controller uses the stableService if Rollout does not specify the rootService field
  backends:
  - service: demo
    weight: 10
  - service: demo-canary
    weight: 90

---
apiVersion: v1
kind: Service
metadata:
  name: demo-smi
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: demo
    version: blue
  type: ClusterIP

---
apiVersion: v1
kind: Service
metadata:
  name: demo
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: demo
    version: blue
  type: ClusterIP

---
apiVersion: v1
kind: Service
metadata:
  name: demo-canary
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: demo
    version: blue
  type: ClusterIP

---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: rollout-ing
spec:
  entryPoints:
    - websecure
  routes:
    - kind: Rule
      match: Host(`mycompagny.com`) 
      services:
        - name: demo-smi
          port: 80
  tls:
    certResolver: myresolver

applications.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: net

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: rollout
  namespace: argocd
spec:
  project: default
  source:
    repoURL: git@github.com:telemaqueHQ/DevOps.git
    targetRevision: master
    path: gitOps/test/argocd
  destination:
    server: https://kubernetes.default.svc
    namespace: net
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

4

0 回答 0