Is it possible to deploy kubernetes application through bazel?

8/27/2019

i want to automate the deployment procedure of my kubernetes pod manifest file through bazel. I have gone through k8s_object in bazel which takes information of the k8s context, cluster and kubeconfig file , not sure how i can make use of it to deploy my application in k8s tenant.

-- Manish Thakur
bazel
kubernetes

1 Answer

8/28/2019

You need to use the k8s_object to interact with Kubernetes cluster.

You can create a Deployment that will deploy your application to the cluster:

Here is an example nginx-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

You have to use that yaml file as a template in the bazel k8s_object, so it would look like this: k8s_object(name = "nginx", kind = "create", template = "nginx-deployment.yaml")

-- Crou
Source: StackOverflow