forked from kubernetes-retired/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tls support and more reliable service health check
- Loading branch information
Wilson, Dan
committed
Feb 22, 2016
1 parent
ee01df4
commit 0167f5d
Showing
7 changed files
with
137 additions
and
30 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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
|
||
# Kubernetes Continuous Delivery | ||
Deployment scripts for continuous integration and\or continuous delivery of kubernetes projects. This project was tested and released using a private install of both CircleCI and Jenkins. The core deployments scripts (./deploy/) are used for both systems and as a result are designed to be extensible. Please contribute to add features and support for different CI/CD systems as needed. | ||
Deployment scripts for continuous integration and\or continuous delivery of kubernetes projects. This project was tested and released using a private installs of CircleCI, Jenkins and SolanoCI. The core deployments scripts (./deploy/) are used for all three systems and as a result are fairly robust and compatible for other systems to use. Please contribute to add features and support for different CI/CD systems as needed. | ||
|
||
The idea of these scripts was based off of the [docker-hello-google example on circleci repo](https://github.com/circleci/docker-hello-google). Thank you for giving us all a head start! | ||
|
||
## Usage | ||
|
||
In general, the documentation for scripts is handled inline with comments. You must have a [kubernetes config](http://kubernetes.io/v1.0/docs/user-guide/kubeconfig-file.html) file available and accessible to your build system from a URL. An S3 URL was used in testing. The files from this project should be added to your existing github project (minus the Dockerfile, package.json and server.js that are here just for testing). If you want to make sure your config file is cached an not downloaded with each run then md5sum the config file and update the KUBECHECKSUM variable in circle.yml or jenkins.sh. ~~See build environment setup instructions for Jenkins and CircleCI if you don't currently have an environment setup.~~ <- TODO. | ||
In general, the documentation for scripts is handled inline with comments. You must have a [kubernetes config](http://kubernetes.io/v1.0/docs/user-guide/kubeconfig-file.html) file available and accessible to your build system from a URL. An S3 URL was used in testing. The files from this project should be added to your existing github project (minus the Dockerfile, package.json and server.js that are here just for testing). If you want to make sure your config file is cached an not downloaded with each run then md5sum the config file and update the KUBECHECKSUM variable in circle.yml or jenkins.sh. | ||
|
||
You CI build servers need to have docker installed and in the case of Jenkins and CircleCI the docker socket must be accessible from inside docker containers (sudo chmod 777 /var/run/docker.sock). This would be a security issue for a cloud provider but since we're working on our own private CI system here and we trust our own containers this is not a problem. This is critical for getting docker caching to work between builds until docker caching is available between docker daemon restarts. For CircleCI there are a few extra steps that should be a part of your bootstrap scipts. | ||
|
||
echo 'DOCKER_OPTS="-g /data/docker"' | sudo tee -a /etc/default/docker | ||
export CIRCLE_SHARED_DOCKER_ENGINE=true | ||
|
||
SolanoCI has Docker caching built into their on-premise platform as a part of a beta release. Reach out to them for special instructions for applying that release. | ||
|
||
You must have at least one running kubernetes cluster. If you intend to deploy to production install multiple kubernetes clusters and run the deploy command multiple times with the different context names from your kube config file. | ||
|
||
|
@@ -32,11 +39,18 @@ chmod +x ./jenkins.sh && ./jenkins.sh | |
6. push changes to github and check the Jenkins job console output for errors\success messages. | ||
|
||
## Circle CI | ||
1. Update the circle.yaml environment variables to fit your environment. | ||
1. Update the circle.yml environment variables to fit your environment. | ||
2. Link your project to Circle CI | ||
3. Manually set the docker $dockeruser and $dockerpass environment variables on your CircleCI project. NOTE: going this route so that the credentials are not stored in your github account. | ||
4. Run a build. | ||
3. Check the job output for any errors and the deploy script output for the proxy api endpoint to hit your service for any manual testing. | ||
5. Check the job output for any errors. The deploy script output prints the api proxy endpoint to hit your service for any manual testing and a link to kibana. | ||
|
||
## Solano CI | ||
1. Update the solano.yml environment variables to fit your environment. | ||
2. Link your project to SolanoCI | ||
3. Manually set the docker $dockeruser and $dockerpass environment variables on your solano project using the solano config:add command. NOTE: going this route so that the credentials are not stored in your github account. | ||
4. Run a build. | ||
5. Check the job output for any errors. The deploy script output prints the api proxy endpoint to hit your service for any manual testing and a link to kibana. | ||
|
||
##### Author | ||
Dan Wilson: [email protected] |
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
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
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
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
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
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,59 @@ | ||
system: | ||
docker: true | ||
|
||
environment: | ||
###!!! variable expansion is not available in solanoci so dynamic vars are handled as a special case by forcing evaluation in each build\test step !!!### | ||
# a url that your ci system can hit to pull down your kube config file | ||
KUBEURL: http:// | ||
KUBECHECKSUM: a1e27f4bfad4df1de8f9a4662223dac7 | ||
# contexts from your kubeconfig file that are used for deployment | ||
KUBECONTEXTQA: aws_kubernetes | ||
KUBECONTEXTPROD: aws_kubernetes2 | ||
# update this to the directory where your yaml\json files are for kubernetes relative to your project root directory | ||
|
||
KUBEDEPLOYMENTDIR: ./kubeyaml | ||
BUILD: ${TDDIUM_TEST_EXEC_ID} | ||
#BUILD is set to the following value in deploy-service.sh: ${TDDIUM_TEST_EXEC_ID} | ||
# used for interpod and interservice communication | ||
# Must be lowercase and <= 24 characters | ||
|
||
SERVICENAME: '$(git config user.email | awk -F@ ''{print substr($1,1,8)}'' | tr [A-Z] [a-z])-$(echo ${TDDIUM_REPO_ROOT} | awk -F/ ''{print "s" substr($NF,1,14)}'' | tr -d ''_-'' | tr [A-Z] [a-z])' | ||
|
||
# the docker repo | ||
DOCKER_REGISTRY: docker-registry.yourcompany.com | ||
|
||
# the docker container defaulted to user/project | ||
CONTAINER1: '$(git config user.email | awk -F@ ''{print substr($1,1,8)}'' | tr [A-Z] [a-z])/$(echo ${TDDIUM_REPO_ROOT} | awk -F/ ''{print "s" substr($NF,1,14)}'' | tr -d ''_-'' | tr [A-Z] [a-z])' | ||
|
||
timeout_hook: 900 | ||
cache: | ||
save_paths: | ||
- "HOME/.kube" | ||
|
||
hooks: | ||
pre_setup: | | ||
eval BUILD=${BUILD} | ||
eval SERVICENAME=${SERVICENAME} | ||
eval CONTAINER1=${CONTAINER1} | ||
chmod +x ./deploy/ensure-kubectl.sh | ||
./deploy/ensure-kubectl.sh ${KUBEURL} | ||
set +x | ||
echo ${DOCKER_REGISTRY}/${CONTAINER1} | ||
sudo docker build -t ${DOCKER_REGISTRY}/${CONTAINER1} . | ||
pre: npm install | ||
|
||
nodejs: | ||
version: '0.10.31' | ||
|
||
tests: | ||
- | | ||
set -e | ||
eval BUILD=$BUILD | ||
eval SERVICENAME=$SERVICENAME | ||
eval CONTAINER1=$CONTAINER1 | ||
sudo docker run -p 3000 --label ${CONTAINER1} ${DOCKER_REGISTRY}/${CONTAINER1} bash -c "npm test" | ||
sudo docker tag -f ${DOCKER_REGISTRY}/${CONTAINER1}:latest ${DOCKER_REGISTRY}/${CONTAINER1}:build${TDDIUM_TEST_EXEC_ID} | ||
sudo docker push ${DOCKER_REGISTRY}/${CONTAINER1}:build${TDDIUM_TEST_EXEC_ID} | ||
sudo docker push ${DOCKER_REGISTRY}/${CONTAINER1}:latest | ||
chmod +x ./deploy/deploy-service.sh | ||
./deploy/deploy-service.sh ${KUBECONTEXTQA} ${KUBEDEPLOYMENTDIR} |