Kubernetes
Squash has native support for Kubernetes (k8s). Currently this option is only available through the Squash YAML file.
In order to get started you need to add the deployment_type: kubernetes
field in the Squash YAML file, for all applications that are Kubernetes based. Then use our Kubernetes specific YAML file fields to customize your applications to fit your needs.
Below you will find some sample Squash YAML files illustrating some common use cases:
Example 1: Kubernetes image
For this example we are showing how to define Kubernetes images in a deployment.
deployments: MyAppName: kubernetes_build_image: nginx deployment_type: kubernetes use_kubernetes_registry: true
Example 2: Multiple apps and Helm charts
Here we are defining multiple apps based on helm charts from a single Squash YAML file.
deployments: odoo: kubernetes_helm_chart: stable/odoo kubernetes_helm_parameters: odooPwd=pwd,psql.pslqPwd=secret deployment_type: kubernetes kubernetes_service: odoo drupal: kubernetes_helm_chart: stable/drupal deployment_type: kubernetes kubernetes_service: drupal apache: kubernetes_helm_chart: bitnami/apache deployment_type: kubernetes kubernetes_service: apache kubernetes_helm_repository: bitnami https://charts.io/xyz
Example 3: Manifest and port forwarding
Here we are using a multi config scenario with manifests and port forwarding.
deployments: multiconfigApp: kubernetes_manifest: pod.yml, pod2.yml deployment_type: kubernetes kubernetes_default_image: rss-site kubernetes_port_mapping: redmine:3000 subdomain_port_mapping: redmine:3000
Example 4: Multiple helm charts and subdomain port mapping
For this example we are defining multiple helm charts for the same application and associating specific container ports with a Squash subdomain.
deployments: MyApp: kubernetes_helm_chart: - stable/drupal - bitnami/apache - kiwigrid/graphite deployment_type: kubernetes kubernetes_service: drupal kubernetes_default_pod: drupal kubernetes_helm_repository: - bitnami https://charts.bitnami.com/bitnami - kiwigrid https://kiwigrid.github.io kubernetes_port_mapping: - svc/apache:3000:80 - svc/graphite:8080 subdomain_port_mapping: - apache:3000 - graphite:8080
Example 5: Using a private registry
Here we are using a private registry to build the k8s cluster. You can also use Squash Environment Variables to keep the REGISTRY_PASSWORD secured.
deployments: MyApp: kubernetes_helm_chart: stable/drupal deployment_type: kubernetes kubernetes_service: odoo docker_registry: server: example.io username: myapp_user password: $REGISTRY_PASSWORD
Example 6: Using the "install" field for greater control
The install field gives you greater flexibility during the setup of your Kubernetes cluster, allowing you to take full control of the startup order and packages to install. Example Squash YAML file:
deployments: MyApp: install: - kubectl label namespace default istio-injection=enabled - kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml - kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml - export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}') - export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}') - export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT - kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml - kubectl create ns foo - kubectl apply -f <(istioctl kube-inject -f samples/httpbin/httpbin.yaml) -n foo - kubectl apply -f <(istioctl kube-inject -f samples/sleep/sleep.yaml) -n foo
For more information please check our Kubernetes specific YAML file fields.