dockerubuntukubernetes-podk3s

Run docker container on k3s-agent from k3s-master


I made one k3s-master on ubuntu 20 and one k3s-agent on another ubuntu 20. I have both system connected to same network.I have docker image on k3s-agent, I can able to run the container on k3s-agent.I created one cluster and k3s-agent and k3s-master both are connected to cluster. I checked with kubectl get nodes command on master and I can see agent and master are listed.

I need help on following points. I want to run docker image on k3s-agent from k3s-master. Is there any way to run docker image on agent from master ?

I came to know that I can make pod and using pod I can do that. but pod is not working out.


Solution

  • There are two things we can do.

    1. nodeName,

    Just mention the nodeName: mynode1 in yaml file.

    1. taints and toleration

    We can set Taints and Toleration inside pod`s yaml file. Example below.

    set Taints to node like this

    kubectl taint nodes mynode1 app=Device:NoSchedule
    

    and we can toleration in yaml file as below.

    apiVersion: v1
    kind: Pod
    metadata:
      name: scriptpod
    spec:
      containers:
        - name: scriptdo
          image: scriptdo
          imagePullPolicy: Always
    nodeName: mynode1
    restartPolicy: Always
    tolerations:
    - key: "app"
      operator: "Equal"
      value: "Device"
      effect: "NoSchedule"
    

    Document for taints and toleration

    Note:- I set nodeName and taints and toleration both, cause nodeName not worked in rare case.