Kops: Kops should have a one-liner to export .yaml for cluster and instance group specs

Created on 1 Feb 2017  Â·  8Comments  Â·  Source: kubernetes/kops

This would be great to export your configuration and then use kubectl create -f to recreate your cluster at a later time/date.

I don't think that this exists yet, and if it does, we could provide better documentation visibility for a feature that should be useful.

If others like the idea and we can come up with syntax that folks would be happy with, I will take a crack at this for 1.5.1. Re: syntax, kops export seems so far to be only related to exporting kube_config files. I think this may be a good place to start, perhaps with flags to choose to export just the cluster spec, one or more igs, or cluster spec and one or more igs, or export all.

Most helpful comment

We have kops get -o yaml now ;) Closing

All 8 comments

kop get cluster --full -o yaml is the cluster. Same for ig. Once command would be nice. Kinda like a cluster-info with kubectl

The following commands work to get the cluster spec and the concatenated intancegroup specs:

kops get cluster --name <cluster-name> --output yaml
kops get ig --name <cluster-name> --output yaml

I would expect this to work to get the full spec, by not specifying the subcommand:

kops get --name <cluster-name> --output yaml

And it's in line with what kops already tells you is possible:

$ kops get -h
list or get objects

Usage:
  kops get [command]

Available Commands:
  clusters       get clusters
  federations    get federations
  instancegroups get instancegroups
  secrets        get secrets

Flags:
  -o, --output string   output format.  One of: table, yaml, json (default "table")

Global Flags:
      --alsologtostderr                  log to standard error as well as files
      --config string                    config file (default is $HOME/.kops.yaml)
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --logtostderr                      log to standard error instead of files (default false)
      --name string                      Name of cluster
      --state string                     Location of state storage (default "s3://kops-skyscrape-rs-state")
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                          log level for V logs
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

Use "kops get [command] --help" for more information about a command.

For what it's worth there are a few issues with what is there currently:

  • get cluster does not put a yaml separator between the cluster definition and the master instance group
  • get ig does not support --full
  • get secrets does not support yaml.

Without the secrets you cannot boot the cluster, so seems far from working right now.

get cluster does not put a yaml separator between the cluster definition and the master instance group

Please provide more details

get ig does not support --full

--full is only used for debugging. This would be a new feature

get secrets does not support yaml

Not sure what would be the purpose of exporting the secrets. Are you trying to back up the full configuration of a cluster?

Hmmn, weird. I can't repro (1) on my windows machine. I'll check tomorrow on my mac, maybe I was mistaken or it is a version thing.

What I'm trying to do is export a configuration like the OP is that I can deploy at a later date. Rather than go through the rigmarole of create cluster/edit cluster/edit ig/update cluster each time. But it seems that's not possible and it seems I can't apply a partial update to a created configuration either. So this slightly tedious process (kops obviously takes a lot of the pain out of things) is the only way?

We have kops get -o yaml now ;) Closing

@chrislovecnm:

kop get cluster --full -o yaml is the cluster. Same for ig. Once command would be nice. Kinda like a cluster-info with kubectl

Not the same: --full includes all sorts of things that you cannot leave in a cluster YAML that you want to create a cluster with.

kops get cluster -o yaml doesn't export all configurations.

Seems edit cluster has extra details.

➤ diff edit.output get.output
40,45d39
<   masterInternalName: api.internal.example.com
<   masterPublicName: api.example.com
<   networkCIDR: 172.20.0.0/16
<   networking:
<     kubenet: {}
<   nonMasqueradeCIDR: 100.64.0.0/10
Was this page helpful?
0 / 5 - 0 ratings

Related issues

olalonde picture olalonde  Â·  4Comments

drewfisher314 picture drewfisher314  Â·  4Comments

Caskia picture Caskia  Â·  3Comments

mikejoh picture mikejoh  Â·  3Comments

chrislovecnm picture chrislovecnm  Â·  3Comments