Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Daemonset using kubectl?

I took the CKA exam and I needed to work with Daemonsets for quite a while there. Since it is much faster to do everything with kubectl instead of creating yaml manifests for k8s resources, I was wondering if it is possible to create Daemonset resources using kubectl.

I know that it is NOT possible to create it using regular kubectl create daemonset at least for now. And there is no description of it in the documentation. But maybe there is a way to do that in some different way?

The best thing I could do right now is to create Deployment first like kubectl create deployment and edit it's output manifest. Any options here?

like image 718
Adilet Maratov Avatar asked Sep 04 '18 08:09

Adilet Maratov


2 Answers

It's impossible. At least for Kubernetes 1.12. The only option is to get a sample Daemonset yaml file and go from there.

like image 159
Adilet Maratov Avatar answered Sep 27 '22 15:09

Adilet Maratov


The fastest way to create

kubectl create deploy nginx --image=nginx --dry-run -o yaml > nginx-ds.yaml

Now replace the line kind: Deployment with kind: DaemonSet in nginx-ds.yaml and remove the line replicas: 1 , strategy {} and status {} as well. Otherwise it shows error for some required fields like this

error: error validating "nginx-ds.yaml": error validating data: [ValidationError(DaemonSet.spec): unknown field "strategy" in io.k8s.api.apps.v1.DaemonSetSpec, ValidationError(DaemonSet.status): missing required field "currentNumberScheduled" in io.k8s.api.apps.v1.DaemonSetStatus,ValidationError(DaemonSet.status): missing required field "numberMisscheduled" in io.k8s.api.apps.v1.DaemonSetStatus, ValidationError(DaemonSet.status): missing required field "desiredNumberScheduled" in io.k8s.api.apps.v1.DaemonSetStatus, ValidationError(DaemonSet.status): missing required field "numberReady" in io.k8s.api.apps.v1.DaemonSetStatus]; if you choose to ignore these errors, turn validation off with --validate=false
like image 21
araza Avatar answered Sep 27 '22 16:09

araza