<p>I want to automate the deployment procedure of my kubernetes pod manifest file through Bazel. I have gone through <code>k8s_object</code> 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.</p>

Manish Thakur
<p>You need to use the <a href="https://github.com/bazelbuild/rules_k8s#k8s_object" rel="nofollow noreferrer">k8s_object</a> to interact with Kubernetes cluster.</p>

<p>You can <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment" rel="nofollow noreferrer">create a Deployment</a> that will deploy your application to the cluster:</p>

<p>Here is an example <code>nginx-deployment.yaml</code>:</p>

<pre><code>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
</code></pre>

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