Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl Export is deprecated . Any alternative

I'm looking for a way to export a yaml file from a deployed component but without the cluster specific information.

kubectl get MYOBJECT --export -o yaml > my.yaml 

but since "export" is now deprecated (since 1.14 and should normally disappear in 1.18 (didn't find it in changelog), what would be an alternative ?

thanks

like image 863
Bobbob601 Avatar asked Apr 23 '20 16:04

Bobbob601


People also ask

How do you expose cluster IP in Kubernetes?

From the Service type drop-down list, select Node port. Click Expose. When your Service is ready, the Service details page opens, and you can see details about your Service. Under Ports, make a note of the Node Port that Kubernetes assigned to your Service.

Which sub command of kubectl we can use to scale an application?

kubectl autoscale creates a HorizontalPodAutoscaler (or HPA) object that targets a specified resource (called the scale target) and scales it as needed.

What is kubectl short for?

Kubernetes provides a command line tool for communicating with a Kubernetes cluster's control plane, using the Kubernetes API.

Is kubectl create being deprecated?

That's not quite accurate, kubectl create has several sub-commands which allow you to create resources without writing yaml, there's no pod creation, but that part of kubectl run is not being deprecated.

What happened to the ‘Export’ flag in kubectl?

The ‘export’ flag in kubectl was deprecated in 1.18, but you still need a way to dump the yaml of Kubernetes objects, often for the purpose of reapplying changes.

Can kubectl export all API objects from a running cluster?

It would be very use for kubectl to be able to export all api objects in a namespace from a running cluster to JSON/YAML files, and import that state from files to another cluster.

What does the Kubernetes deprecation message hints at?

What the deprecation message hints (and is also clarified by the answer provided by @soltysh) is that the particular practice will be removed. So in future kubernetes versions, the run command will by default (and as only option) create pods (and not deployments), i.e. the command in its full extend will become:


1 Answers

Using JQ does the trick.

kubectl get secret <secretname> -ojson | jq 'del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid) | .metadata.creationTimestamp=null' 

produces exactly the same JSON as

kubectl get secret <secretname> -ojson --export 
like image 134
adel-s Avatar answered Sep 16 '22 17:09

adel-s