项目作者: josue

项目描述 :
Generate alpha URL deployments on Kubernetes using Helm + Ambassador
高级语言: Smarty
项目地址: git://github.com/josue/k8s-alpha-deployments.git
创建时间: 2019-07-03T19:41:38Z
项目社区:https://github.com/josue/k8s-alpha-deployments

开源协议:

下载


About Kubernetes Alpha Deployments

Using Helm with Ambassador, you can generate routes for alpha deployments that are routed to your own CNAME (ie: *.alpha)

Hence, developers can deploy their alpha build (app) to a k8s namespace (alpha) and then use this build to test their app before merging to the mainline repo.

On helm release deploy, this would generate a dynamic alpha URL which uses the Values app + commit hash to create the deployment publicly available host.

Example Alpha URL: http://api-e78587c397.alpha.domain.com

Installation & Deployment Steps:

  1. Instead Ambassador, like:

    1. helm upgrade --install --wait my-ambassador stable/ambassador
  2. Extract the the Ambassador k8s service External IP:

    1. kubectl get svc -o wide ambassador
    2. `

    expected output:

    1. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
    2. ambassador LoadBalancer 10.x.x.x 35.x.x.x 80:31131/TCP 17m service=ambassador
  3. Create the following DNS entry with the Ambassador External IP:

Type Name Value
CNAME *.alpha 35.x.x.x
  1. Modify the Values.yaml file with your repo’s app name and the repo’s latest commit:

Example Values.yaml required:

  1. app: api
  2. commit: e78587c397e259747e6bc52e39aff1c8887fb279
  1. On your CI/CD deployments (ie: Jenkins, etc) create a Helm release for your application:
  1. helm upgrade --debug --install --wait alpha-app-1 ./alpha

Example template populated during release:

  1. ---
  2. # Source: alpha/templates/service.yaml
  3. apiVersion: v1
  4. kind: Service
  5. metadata:
  6. app: api
  7. name: api-e78587c397
  8. namespace: alpha
  9. alpha.deploy: true
  10. annotations:
  11. getambassador.io/config: |
  12. ---
  13. apiVersion: ambassador/v1
  14. kind: Mapping
  15. name: api-e78587c397
  16. host: api-e78587c397.alpha.domain.com
  17. prefix: /
  18. service: api-e78587c397.alpha:80
  19. spec:
  20. selector:
  21. app: api-e78587c397
  22. ports:
  23. - protocol: TCP
  24. port: 80
  25. ---
  26. # Source: alpha/templates/deployment.yaml
  27. apiVersion: extensions/v1beta1
  28. kind: Deployment
  29. metadata:
  30. app: api
  31. name: api-e78587c397
  32. namespace: alpha
  33. alpha.deploy: true
  34. spec:
  35. replicas: 1
  36. strategy:
  37. type: RollingUpdate
  38. template:
  39. metadata:
  40. labels:
  41. app: api-e78587c397
  42. spec:
  43. containers:
  44. - name: httpd
  45. image: "httpd"
  46. ports:
  47. - containerPort: 80

The above will output a message like the following with the alpha URL where the application has deployed:

Alpha URL: http://api-e78587c397.alpha.domain.com


Note: You can create a weekly cronjob to delete all alpha deployments after inactivity.

To delete the existing Helm release:

  1. helm delete alpha-app-1