Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posting raw yaml or json to the api #325

Closed
Stono opened this issue May 15, 2018 · 2 comments
Closed

Posting raw yaml or json to the api #325

Stono opened this issue May 15, 2018 · 2 comments

Comments

@Stono
Copy link

Stono commented May 15, 2018

Hey,
I'm just wondering if there is any way to post the raw json or yaml kubernetes spec's that I already have via this gem? I have some existing yaml files that I don't really want to rewrite, and just want to read them from disk and use this gem to post them off.

eg, how do I turn resource_json = YAML.load_file('echo-server/kubernetes/service.yaml').to_h into Kubeclient::Resource?

instead of the example:

service = Kubeclient::Resource.new
service.metadata = {}
service.metadata.name = "redis-master"
service.metadata.namespace = 'staging'
service.spec = {}
service.spec.ports = [{
  'port' => 6379,
  'targetPort' => 'redis-server'
}]
service.spec.selector = {}
service.spec.selector.name = "redis"
service.spec.selector.role = "master"
service.metadata.labels = {}
service.metadata.labels.app = 'redis'
service.metadata.labels.role = 'slave'
client.create_service(service)

Is this even possible?

@Stono
Copy link
Author

Stono commented May 15, 2018

Sussed it by reading #187

resource = Kubeclient::Resource.new(YAML.load_file('echo-server/kubernetes/service.yaml'))

@Stono Stono closed this as completed May 15, 2018
@cben
Copy link
Collaborator

cben commented May 15, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants