FluxCD镜像自动化更新配置:已完成部分操作,求后续指导
Flux自动化镜像更新配置求助
我正在使用Flux、GitHub Actions、DockerHub和Kubernetes部署Web应用。当前通过GitHub Actions自动删除旧Pod,让Flux创建更新后的新Pod的方式过于原始,因此尝试配置Flux实现镜像/应用的自动化更新。
目录结构
├── flux-system │ ├── gotk-components.yaml │ ├── gotk-sync.yaml │ ├── kustomization.yaml │ └── restaurant.yaml └── restaurant-app ├── deployment.yaml ├── image-automation │ ├── imagepolicy.yaml │ ├── imagerepo.yaml │ ├── imageupdate.yaml │ └── kustomization.yaml ├── kustomization.yaml └── service.yaml
各配置文件内容
imageupdate.yaml
apiVersion: image.toolkit.fluxcd.io/v1beta2 kind: ImageUpdateAutomation metadata: name: restaurant-update namespace: flux-system spec: interval: 1m sourceRef: kind: GitRepository name: flux-system namespace: flux-system git: checkout: ref: branch: main commit: author: name: FluxCD email: fluxcd@example.com messageTemplate: "Update image to {{range .Updated.Images}}{{.}}{{end}}" push: branch: main update: strategy: Setters
imagepolicy.yaml
apiVersion: image.toolkit.fluxcd.io/v1beta2 kind: ImagePolicy metadata: name: restaurant-latest namespace: flux-system spec: imageRepositoryRef: name: restaurant policy: semver: range: 1.0.x
imagerepo.yaml
apiVersion: image.toolkit.fluxcd.io/v1beta2 kind: ImageRepository metadata: name: restaurant namespace: flux-system spec: image: tyvenchr/restaurant-landing-page interval: 1m
service.yaml
apiVersion: v1 kind: Service metadata: name: restaurant-landing namespace: default spec: selector: app: restaurant-landing ports: - protocol: TCP port: 80 targetPort: 3000 type: NodePort
deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: restaurant-landing spec: replicas: 1 selector: matchLabels: app: restaurant-landing template: metadata: labels: app: restaurant-landing spec: containers: - name: web image: tyvenchr/restaurant-landing-page imagePullPolicy: Always ports: - containerPort: 3000
restaurant.yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization metadata: name: restaurant namespace: flux-system spec: interval: 1m path: ./clusters/my-cluster/restaurant-app prune: true sourceRef: kind: GitRepository name: flux-system
flux-system/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - gotk-components.yaml - gotk-sync.yaml - restaurant.yaml
restaurant-app/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: default resources: - deployment.yaml - service.yaml - image-automation/ images: - name: tyvenchr/restaurant-landing-page newTag: 1.0.6 # optional, Flux will update this # {"$imagepolicy": "flux-system:restaurant-latest")
restaurant-app/image-automation/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - imagepolicy.yaml - imagerepo.yaml - imageupdate.yaml
我完全不清楚下一步该怎么做,恳请帮助。
内容的提问来源于stack exchange,提问作者Tyven Christopher
相关产品推荐
相关产品推荐

