Skip to content

Commit

Permalink
(ci) fix deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanrahic committed Nov 28, 2018
1 parent 4af3e3d commit 126fefb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .semaphore/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ blocks:
- checkout
- export GIT_HASH=$(git log --format=format:'%h' -1)
- export TAG=${SEMAPHORE_GIT_BRANCH}_${GIT_HASH}_${SEMAPHORE_WORKFLOW_ID}
- docker pull $API_IMAGE:$TAG
- docker pull $CLIENT_IMAGE:$TAG
- docker images
- ls $HOME/.kube
- kubectl apply -f api-deployment.yaml
- kubectl apply -f client-deployment.yaml
- docker pull $API_IMAGE:$TAG
- envsubst '${TAG}' <api-deployment.yaml > api-deployment.prod.yaml
- envsubst '${TAG}' <client-deployment.yaml > client-deployment.prod.yaml
- kubectl apply -f api-deployment.prod.yaml
- kubectl apply -f client-deployment.prod.yaml

# - echo "Configure KOPS config to enable kubectl to talk to the KOPS cluster."
# - echo "'kubectl apply -f api-deployment.yml' - the image value will be '$API_IMAGE:$SEMAPHORE_BUILD_NUMBER' - no need to generate new file for every deploy"
Expand Down
2 changes: 1 addition & 1 deletion api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ spec:
- containerPort: 3000
resources: {}
restartPolicy: Always
status: {}
status: {}
25 changes: 25 additions & 0 deletions kops.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export ORGANIZATION_NAME=<your_org_name>

# create state store
export BUCKET_NAME=${ORGANIZATION_NAME}-kops-state-store
aws s3api create-bucket --bucket ${BUCKET_NAME} --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1
aws s3api put-bucket-versioning --bucket ${BUCKET_NAME} --versioning-configuration Status=Enabled

# create cluster
export KOPS_CLUSTER_NAME=${ORGANIZATION_NAME}.k8s.local
export KOPS_STATE_STORE=s3://${BUCKET_NAME}

# define cluster config
kops create cluster --master-count=1 --master-size=t2.micro --node-count=1 --node-size=t2.micro --zones=eu-west-1a --name=${KOPS_CLUSTER_NAME}

# if you want to edit config
kops edit cluster --name ${KOPS_CLUSTER_NAME}

# apply and create cluster
kops update cluster --name ${KOPS_CLUSTER_NAME} --yes

# validate cluster is running
kops validate cluster

# export kubectl config file
KUBECONFIG=${HOME}/${KOPS_CLUSTER_NAME}-kubeconfig.yaml kops export kubecfg --name ${KOPS_CLUSTER_NAME} --state ${KOPS_STATE_STORE}

0 comments on commit 126fefb

Please sign in to comment.