-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft(examples): add example usage script
- Loading branch information
Nyambati Thomas
committed
Jun 27, 2018
1 parent
01cd876
commit 0e8571c
Showing
2 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The setup below is a sample of how this K8s deploy scripts can be used. Modification may be required to fit your specific purpose. | ||
set -eo pipefail | ||
|
||
DEPLOY_SCRIPT_PATH="${HOME}/deploy" | ||
|
||
curl -o $DEPLOY_SCRIPT_PATH https://raw.githubusercontent.com/AndelaOSP/bash-helper-modules/master/k8s/deploy | ||
|
||
source $DEPLOY_SCRIPT_PATH | ||
# add the following environment variables to your ci. Change them according to your cluster requirements | ||
# PRODUCTION_GOOGLE_COMPUTE_ZONE | ||
# STAGING_GOOGLE_COMPUTE_ZONE | ||
# STAGING_CLUSTER_NAME | ||
# PRODUCTION_CLUSTER_NAME | ||
# PROJECT_NAME | ||
# GOOGLE_PROJECT_ID | ||
# GCLOUD_SERVICE_KEY | ||
# DOCKER_REGISTRY | ||
|
||
|
||
GCLOUD_SERVICE_KEY_NAME=gcloud-service-key.json | ||
ALLOWED_DEPLOY_ENVIRONMENTS=('staging', 'production') | ||
|
||
require 'PRODUCTION_GOOGLE_COMPUTE_ZONE' $PRODUCTION_GOOGLE_COMPUTE_ZONE | ||
require 'STAGING_GOOGLE_COMPUTE_ZONE' $STAGING_GOOGLE_COMPUTE_ZONE | ||
require 'STAGING_CLUSTER_NAME' $STAGING_CLUSTER_NAME | ||
require 'PRODUCTION_CLUSTER_NAME' $PRODUCTION_CLUSTER_NAME | ||
require 'PROJECT_NAME' $PROJECT_NAME | ||
require 'GOOGLE_PROJECT_ID' $GOOGLE_PROJECT_ID | ||
require 'DOCKER_REGISTRY' $DOCKER_REGISTRY | ||
require 'GCLOUD_SERVICE_KEY' $GCLOUD_SERVICE_KEY | ||
|
||
BRANCH_NAME=$CIRCLE_BRANCH | ||
setEnvironment $BRANCH_NAME | ||
isAllowedDeployEnvironment $ENVIRONMENT | ||
|
||
getDeploymentName DEPLOYMENT_NAME | ||
IMAGE_TAG=$(getImageTag $(getCommitHash)) | ||
IMAGE_NAME=$(getImageName) | ||
|
||
main() { | ||
installGoogleCloudSdk | ||
authWithServiceAccount | ||
configureGoogleCloudSdk | ||
loginToContainerRegistry _json_key | ||
buildAndTagDockerImage -f docker/Dockerfile . | ||
publishDockerImage | ||
logoutContainerRegistry $DOCKER_REGISTRY | ||
deployToKubernetesCluster backend | ||
} | ||
|
||
main | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters