diff --git a/.drone.yml b/.drone.yml index 6315c91..356e1f6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -48,7 +48,7 @@ steps: image: plugins/docker settings: repo: kleph/beer - tags: latest + tags: ${DRONE_COMMIT_SHA:0:8} username: from_secret: dockerhub_username password: @@ -71,11 +71,25 @@ steps: from_secret: kubectl_cert kubernetes_token: from_secret: kubectl_token + environment: + IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8} + NAMESPACE: beer commands: + - echo "== pre deploy status:" - kubectl get pods --namespace=beer - kubectl get deployments --namespace=beer - - kubectl get svc --namespace=beer - - kubectl apply -f kube/beer-deployment.yaml --namespace=beer + - sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-deployment.yaml > kube/beer-deployment-prod.yaml + - sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment-prod.yaml > kube/beer-deployment-prod2.yaml + - echo "applying" + - kubectl apply -f kube/beer-deployment-prod2.yaml --namespace=beer + - echo "== post deploy status:" + - kubectl get deployments --namespace=beer + - kubectl get pods --namespace=beer depends_on: - build + +when: + branch: + include: + - master diff --git a/.yamllint b/.yamllint index 9eaf5ea..35c26b0 100644 --- a/.yamllint +++ b/.yamllint @@ -4,3 +4,6 @@ extends: default rules: indentation: indent-sequences: consistent + line-length: + max: 120 + level: warning diff --git a/kube/beer-deployment.yaml b/kube/beer-deployment.yaml index bf08ebb..5d4aa79 100644 --- a/kube/beer-deployment.yaml +++ b/kube/beer-deployment.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: beer-deployment - namespace: beer + namespace: __NAMESPACE__ spec: selector: matchLabels: @@ -16,7 +16,7 @@ spec: spec: containers: - name: beer - image: kleph/beer + image: kleph/beer:__IMAGE_TAG__ imagePullPolicy: Always ports: - containerPort: 5000 diff --git a/kube/beer-namespace.yaml b/kube/beer-namespace.yaml index 119770a..9120a41 100644 --- a/kube/beer-namespace.yaml +++ b/kube/beer-namespace.yaml @@ -2,6 +2,6 @@ apiVersion: v1 kind: Namespace metadata: - name: beer + name: __NAMESPACE__ labels: - name: beer + name: __NAMESPACE__