A template for a node app using TypeScript deployed to kubernetes
TODO
- Hit "Use This Template" to create the repository
- Enable CircleCI
- In Settings
- Disable "Wikis"
- Disable "Projects"
- Disable "Allow merge commits"
- Disable "Allow rebase merging"
- Enable "Automatically delete head branches"
- Create a new branch
- Commit initial code to the branch (be sure to replace all refernces to web-app-template, and remove these instructions from the README)
- Push the new branch and create a PR
- In Settings -> Branch Protection, create a new rule
- Use "master" as the branch name pattern
- Enable "Require status checks to pass before merging"
- Select the unit tests as required
- Enable "Include administrators"
- Enable "Restrict who can push to matching branches"
- Merge the PR
- Replace web-app-template with the name of your app in all files
- Point the DNS for your domain name at your loadbalancer's external IP (which you can get by running
kubectl get svc --namespace=ingress-nginx
) - Run
npx jskube .kube/setup.ts
- N.B. this will attempt to get an SSL certificate, so you must first point the DNS records at your loadbalancer. - Run
npx jskube .kube/deployment-placeholder.ts
(optional). If you do this, you should be able to load the website at the domain name you selected, but you will have to bypass a warning about a certificate error as it will be using the letsencrypt staging ssl certificate. - Once the certificate is issued successfully and you are happy with the domain name of your service, you can set
stagingTLS
tofalse
in.kube/setup.ts
and re-runnpx jskube .kube/setup.ts
to request production TLS certificates.
- build the typescript etc.
yarn build
- build an initial image
docker build -t forbeslindesay/web-app-template:hotfix-01 .
- push
docker push forbeslindesay/web-app-template:hotfix-01"
- deploy
ENVIRONMENT=staging DOCKERHUB_USERNAME=forbeslindesay CIRCLE_SHA1=hotfix-01 jskube apply -f .kube/deployment
After you follow the instructions for "Setting up a new app". You can configure CI to deploy your app.
- Run
jskube get-env-vars --user cicd --namespace ${namespace}
to get the environment variables for connecting to kubernetes - Get your dockerhub username and password as
DOCKERHUB_USERNAME
andDOCKERHUB_PASS
- Add the environment variables to Circle CI -> web-app-template -> Settings -> Environment Variables (https://circleci.com/gh/ForbesLindesay/web-app-template/edit#env-vars)