publish container image
Less than 1 minute
publish container image
prepare
- argo workflows is ready
- the storage class named
local-disks
is ready
demo
- prepare
publish-container-image.yaml
- dind
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: publish-container-image- spec: entrypoint: entry serviceAccountName: argo-workflow volumeClaimTemplates: - metadata: name: workspace spec: accessModes: - ReadWriteOnce storageClassName: local-disks resources: requests: storage: 1Gi templates: - name: entry dag: tasks: - name: dind template: dind - name: wait-for-dind dependencies: - dind template: wait-for-dind arguments: parameters: - name: dockerd-host value: "{{tasks.dind.ip}}" - name: publish dependencies: - wait-for-dind template: publish arguments: parameters: - name: dockerd-host value: "{{tasks.dind.ip}}" - name: dind daemon: true container: image: docker.io/library/docker:25.0.3-dind-alpine3.19 env: - name: DOCKER_TLS_CERTDIR value: "" command: - dockerd-entrypoint.sh securityContext: privileged: true volumeMounts: - name: workspace mountPath: /workspace - name: wait-for-dind inputs: parameters: - name: dockerd-host container: image: docker.io/library/docker:25.0.3-cli-alpine3.19 env: - name: DOCKER_HOST value: "{{inputs.parameters.dockerd-host}}" command: - sh - -c args: - | until docker ps; do sleep 3; done; - name: publish inputs: artifacts: - name: source path: /workspace/code git: repo: https://github.com/ben-wangz/blog.git revision: main parameters: - name: dockerd-host - name: registry-to-push value: docker.io - name: image-to-publish value: wangz2019/blog-docs:argo-test - name: registry value: docker.io container: image: docker.io/library/docker:25.0.3-cli-alpine3.19 env: - name: DOCKER_HOST value: "{{inputs.parameters.dockerd-host}}" - name: DOCKER_USERNAME valueFrom: secretKeyRef: name: registry-credentials key: username - name: DOCKER_PASSWORD valueFrom: secretKeyRef: name: registry-credentials key: password command: - sh - -c args: - | set -e export REGISTRY={{inputs.parameters.registry}} export REGISTRY_TO_PUSH={{inputs.parameters.registry-to-push}} export IMAGE_TO_PUBLISH=${REGISTRY_TO_PUSH}/{{inputs.parameters.image-to-publish}} bash /workspace/code/docs/src/articles/kubernetes/argocd/argo-workflows/publish-container-image/container/build.sh ${IMAGE_TO_PUBLISH} docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}" ${REGISTRY_TO_PUSH} \ docker push ${IMAGE_TO_PUBLISH} volumeMounts: - name: workspace mountPath: /workspace
buildahapiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: publish-container-image- spec: entrypoint: entry serviceAccountName: argo-workflow templates: - name: entry dag: tasks: - name: publish template: publish - name: publish inputs: artifacts: - name: source path: /workspace/code git: repo: https://github.com/ben-wangz/blog.git revision: main parameters: - name: registry-to-push value: docker.io - name: image-to-publish value: wangz2019/blog-docs:argo-buildah-test - name: registry value: docker.io container: image: quay.io/containers/buildah:v1.35.4 securityContext: privileged: true env: - name: REGISTRY_USERNAME valueFrom: secretKeyRef: name: registry-credentials key: username - name: REGISTRY_PASSWORD valueFrom: secretKeyRef: name: registry-credentials key: password command: - sh - -c args: - | set -e export REGISTRY={{inputs.parameters.registry}} export REGISTRY_TO_PUSH={{inputs.parameters.registry-to-push}} export IMAGE_TO_PUBLISH=${REGISTRY_TO_PUSH}/{{inputs.parameters.image-to-publish}} bash /workspace/code/docs/src/articles/kubernetes/argocd/argo-workflows/publish-container-image/container/build.sh ${IMAGE_TO_PUBLISH} buildah push --creds ${REGISTRY_USERNAME}:${REGISTRY_PASSWORD} ${IMAGE_TO_PUBLISH}
- prepare
registry-credentials
secret#REGISTRY_INSECURE=false #REGISTRY=REGISTRY #REGISTRY_USERNAME=your-username #REGISTRY_PASSWORD=your-password kubectl -n business-workflows create secret generic registry-credentials \ --from-literal="insecure=${REGISTRY_INSECURE:-false}" \ --from-literal="registry=${REGISTRY:-docker.io}" \ --from-literal="username=${REGISTRY_USERNAME:-wangz2019}" \ --from-literal="password=${REGISTRY_PASSWORD}"
- submit with argo workflow client
argo -n business-workflows submit publish-container-image.yaml
- check status
argo -n business-workflows list
# argo -n business-workflows get publish-container-image-2j5z2 argo -n business-workflows get @lastest
# argo -n business-workflows logs publish-container-image-2j5z2 argo -n business-workflows logs @latest