This commit is contained in:
parent
16117618e1
commit
43f338ecf3
3 changed files with 99 additions and 88 deletions
179
.drone.yml
179
.drone.yml
|
@ -1,3 +1,98 @@
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build image
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: kleph/beer
|
||||||
|
tags: ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
username:
|
||||||
|
from_secret: dockerhub_username
|
||||||
|
password:
|
||||||
|
from_secret: dockerhub_password
|
||||||
|
|
||||||
|
#depends_on:
|
||||||
|
#- unit tests
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: deploy-staging
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy-staging
|
||||||
|
image: sinlead/drone-kubectl
|
||||||
|
settings:
|
||||||
|
kubernetes_server:
|
||||||
|
from_secret: kubectl_uri
|
||||||
|
kubernetes_cert:
|
||||||
|
from_secret: kubectl_cert
|
||||||
|
kubernetes_token:
|
||||||
|
from_secret: kubectl_token
|
||||||
|
environment:
|
||||||
|
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
commands:
|
||||||
|
- export NAMESPACE=beer-staging-${DRONE_COMMIT_SHA:0:4}
|
||||||
|
- echo "== create staging namespace $${NAMESPACE}"
|
||||||
|
- sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-namespace.yaml > kube/beer-namespace-staging.yaml
|
||||||
|
- kubectl apply -f kube/beer-namespace-staging.yaml
|
||||||
|
- echo "== deploy staging"
|
||||||
|
- sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment.yaml > kube/beer-deployment-staging.yaml
|
||||||
|
- kubectl apply -f kube/beer-deployment-staging.yaml --namespace=$${NAMESPACE}
|
||||||
|
- echo "== post deploy status:"
|
||||||
|
- kubectl get deployments --namespace=$${NAMESPACE}
|
||||||
|
- kubectl get pods --namespace=$${NAMESPACE}
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
exclude:
|
||||||
|
- master
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: deploy
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy
|
||||||
|
image: sinlead/drone-kubectl
|
||||||
|
settings:
|
||||||
|
kubernetes_server:
|
||||||
|
from_secret: kubectl_uri
|
||||||
|
kubernetes_cert:
|
||||||
|
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
|
||||||
|
- cat kube/beer-deployment.yaml
|
||||||
|
- sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-deployment.yaml > kube/beer-deployment-prod.yaml
|
||||||
|
- cat kube/beer-deployment-prod.yaml
|
||||||
|
- sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment-prod.yaml > kube/beer-deployment-prod2.yaml
|
||||||
|
- echo "applying"
|
||||||
|
- cat kube/beer-deployment-prod2.yaml
|
||||||
|
- 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
|
||||||
|
|
||||||
#---
|
#---
|
||||||
#kind: pipeline
|
#kind: pipeline
|
||||||
#name: lint
|
#name: lint
|
||||||
|
@ -38,87 +133,3 @@
|
||||||
#
|
#
|
||||||
#depends_on:
|
#depends_on:
|
||||||
#- lint
|
#- lint
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: build
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
repo: kleph/beer
|
|
||||||
tags: ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
username:
|
|
||||||
from_secret: dockerhub_username
|
|
||||||
password:
|
|
||||||
from_secret: dockerhub_password
|
|
||||||
|
|
||||||
#depends_on:
|
|
||||||
#- unit tests
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: deploy
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: deploy
|
|
||||||
image: sinlead/drone-kubectl
|
|
||||||
settings:
|
|
||||||
kubernetes_server:
|
|
||||||
from_secret: kubectl_uri
|
|
||||||
kubernetes_cert:
|
|
||||||
from_secret: kubectl_cert
|
|
||||||
kubernetes_token:
|
|
||||||
from_secret: kubectl_token
|
|
||||||
environment:
|
|
||||||
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
NAMESPACE: beer-staging-${DRONE_COMMIT_SHA:0:4}
|
|
||||||
commands:
|
|
||||||
- echo "== create staging namespace ${NAMESPACE}"
|
|
||||||
- kubectl get svc --namespace=${NAMESPACE}
|
|
||||||
- cat kube/beer-deployment.yaml > kube/beer-namespace.yaml
|
|
||||||
- kubectl apply -f kube/beer-namespace.yaml
|
|
||||||
- echo "== deploy staging"
|
|
||||||
- cat kube/beer-deployment.yaml > kube/beer-deployment-${IMAGE_TAG}.yaml
|
|
||||||
- kubectl apply -f kube/beer-deployment-${IMAGE_TAG}.yaml --namespace=beer
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- build
|
|
||||||
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
exclude:
|
|
||||||
- master
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: deploy
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: deploy
|
|
||||||
image: sinlead/drone-kubectl
|
|
||||||
settings:
|
|
||||||
kubernetes_server:
|
|
||||||
from_secret: kubectl_uri
|
|
||||||
kubernetes_cert:
|
|
||||||
from_secret: kubectl_cert
|
|
||||||
kubernetes_token:
|
|
||||||
from_secret: kubectl_token
|
|
||||||
environment:
|
|
||||||
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
commands:
|
|
||||||
- echo "== pre deploy status:"
|
|
||||||
- kubectl get pods --namespace=beer
|
|
||||||
- kubectl get deployments --namespace=beer
|
|
||||||
- kubectl get svc --namespace=beer
|
|
||||||
- cat kube/beer-deployment.yaml > kube/beer-deployment-${IMAGE_TAG}.yaml
|
|
||||||
- kubectl apply -f kube/beer-deployment-${IMAGE_TAG}.yaml --namespace=beer
|
|
||||||
- echo "== post deploy status:"
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- build
|
|
||||||
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: beer-deployment
|
name: beer-deployment
|
||||||
namespace: beer
|
namespace: __NAMESPACE__
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
|
@ -16,7 +16,7 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: beer
|
- name: beer
|
||||||
image: kleph/beer:${IMAGE_TAG}
|
image: kleph/beer:__IMAGE_TAG__
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: ${NAMESPACE}
|
name: __NAMESPACE__
|
||||||
labels:
|
labels:
|
||||||
name: ${NAMESPACE}
|
name: __NAMESPACE__
|
||||||
|
|
Loading…
Reference in a new issue