Skip to content

Latest commit

 

History

History

samples

Ballerina Kubernetes samples

Prerequisites

  1. Install a recent version of Docker for Mac/Windows and enable Kubernetes OR Minikube is installed and running.

  2. Nginx backend and controller deployed.

  3. Mini-kube users should configure following annotations in every sample with valid values:

    @kubernetes:Deployment {
        dockerHost:"tcp://192.168.99.100:2376", 
        dockerCertPath:"/Users/anuruddha/.minikube/certs"
    }
  4. Docker for windows users should enable remote access to the API. (If DOCKER_HOST and DOCKER_CERT_PATH are exported as environment variables, priority will be given to environment variables.) alt tag

  5. Heapster monitoring configured. (This is optional and required only if Horizontal Pod Autoscaler are used. If you are running on GCE, heapster monitoring will be turned-on by default.)

Setting up nginx

  1. Execute the below command to deploy nginx ingress controller.
Docker for mac users:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.0/deploy/static/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.0/deploy/static/provider/cloud-generic.yaml
  1. Execute the below command to enable ssl pass-through.
kubectl patch deployments -n ingress-nginx nginx-ingress-controller -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx-ingress-controller","args":["\/nginx-ingress-controller","--configmap=$(POD_NAMESPACE)\/nginx-configuration","--tcp-services-configmap=$(POD_NAMESPACE)\/tcp-services","--udp-services-configmap=$(POD_NAMESPACE)\/udp-services","--publish-service=$(POD_NAMESPACE)\/ingress-nginx","--annotations-prefix=nginx.ingress.kubernetes.io","--annotations-prefix=nginx.ingress.kubernetes.io","--enable-ssl-passthrough"]}]}}}}'
minikube users:
minikube addons enable ingress
  1. Verify nginx is up and running. (Namespace can be different based on you installation)
$> kubectl get pods --all-namespaces
NAMESPACE       NAME                                         READY     STATUS    RESTARTS   AGE
nginx-ingress   default-http-backend-69c767b879-l6pwj        1/1       Running   0          3d
nginx-ingress   nginx-5667df56c8-8d8ct                       1/1       Running   0          3d

Try kubernetes annotation samples:

  1. Sample1: Kubernetes Hello World
  2. Sample2: Kubernetes Hello World with livenessProbe and hostname mapping
  3. Sample3: Ballerina program with multiple services running in multiple ports
  4. Sample4: Kubernetes Hello World Secured
  5. Sample5: Ballerina service with http and https endpoint
  6. Sample6: Kubernetes Hello World in Google Cloud Environment
  7. Sample7: Mount secret volumes to deployment
  8. Sample8: Mount config map volumes to deployment
  9. Sample9: Mount PersistentVolumeClaim to deployment
  10. Sample10: Ballerina module with kubernetes annotations
  11. Sample11: Kubernetes Hello World with Ballerina Function
  12. Sample12: Copy External files to Docker Image
  13. Sample13: Ballerina modules with dependencies
  14. Sample14: Deploy Ballerina service in a namespace
  15. Sample15: Resource quotas for namespaces
  16. Sample16: Istio Gateway and Virtual Service generation (Remove nginx setting up)
  17. Sample17: OpenShift Build Configs and Routes (Remove nginx setting up)