Bitbucket Pipeline 在EKS的CICD教程3

创建好了你的ECR和EKS的IAM user,接下来就是bitbucket pipeline的yaml编写

image: atlassian/default-image:2
options:
  docker: true
  size: 2x
pipelines:
  branches:
    master2:
      - step:
          name: Build Docker Image
          deployment: Test
          script:
            - >-
              docker build .
              --file api_dockerfile
#             1234.dkr.ecr.ap-southeast-1.amazonaws.com/repoName
              --tag repoName:latest
              --build-arg key=123456app

            - pipe: atlassian/aws-ecr-push-image:1.5.0
              variables:
                AWS_ACCESS_KEY_ID: '你的ECR key'
                AWS_SECRET_ACCESS_KEY: '你的ECR secret'
                AWS_DEFAULT_REGION: 'ap-southeast-1'
                IMAGE_NAME: 'repoName'
                TAGS: 'latest'

            - pipe: atlassian/aws-eks-kubectl-run:2.2.0
              variables:
                AWS_ACCESS_KEY_ID: '你的eks key'
                AWS_SECRET_ACCESS_KEY: '你的eks secret'
                AWS_DEFAULT_REGION: "ap-southeast-1"
                CLUSTER_NAME: "你的集群名"
#               重新部署容器
                KUBECTL_COMMAND: "rollout restart deployment/你的development名 -n 你的namespace"
                DEBUG: "true"

          services:
            - docker
definitions:
  services:
    docker:
      memory: 4096

Loading

Facebook评论