Coder Social home page Coder Social logo

Comments (6)

ericchiang avatar ericchiang commented on May 29, 2024

I'd recommend shelling out to kubectl or using client-go for now. Supporting YAML and JSON serialization for known manifests isn't easy (#8).

I've had the thought of adding a RawResouce, where you could stick a payload then the client would POST whatever's in the body:

type RawResource struct {
    APIVersion string
    Kind       string
    Metadata   v1.ObjectMeta

    ContentType string
    Bytes       []byte
}

but for now, it sounds like you'd probably just want to use kubectl apply -f

from k8s.

wizard580 avatar wizard580 commented on May 29, 2024

the issue: app should support two different clusters, as example 1.7 and 1.11+
yes, I know that we can use kubectl for each version... but it's not nice.

from k8s.

ericchiang avatar ericchiang commented on May 29, 2024

the issue: app should support two different clusters, as example 1.7 and 1.11+

You probably want two different manifest then anyway, right?

yes, I know that we can use kubectl for each version... but it's not nice.

A couple lines of bash sounds nicer to me than messing with untyped YAML and JSON in Go :)

from k8s.

KaelBaldwin avatar KaelBaldwin commented on May 29, 2024

@wizard580

This might not help you, and it's certainly not ideal, but at least to share what worked for my use case:

While using a manifest file that would work with kubernetes doesn't work as is, you could adjust the yaml so that the fields line up with what the unmarshaller is expecting. I used https://github.com/ghodss/yaml for yaml since it transitions through json allowing you to take advantage of the json related tags. (this might not be necessary any more, I see yaml tags have been merged in)

You could also get an existing resource via the library and then marshall it to to yaml and dump it out to a file to get an example of what it needs to look like, I think that would work.

for example a readinessProbe might become:

readinessProbe:
  handler:
    httpGet:
      path: /
      port:
        type: 1
        strval: http
  timeoutSeconds: 1

Once you get used to the differences they are pretty easy to write, they are just a little more verbose, and unfortunately it does require separate manifests for whatever you are using this library for.

from k8s.

cplee avatar cplee commented on May 29, 2024

I love the simplicity of this kubernetes client, but I too am running into this same challenge. Any thoughts on replacing the apis package in this project with kubernetes/api? The resources in that projects support not only protobuf but also YAML and JSON marshalling/unmarshalling

from k8s.

ericchiang avatar ericchiang commented on May 29, 2024

I love the simplicity of this kubernetes client, but I too am running into this same challenge. Any thoughts on replacing the apis package in this project with kubernetes/api? The resources in that projects support not only protobuf but also YAML and JSON marshalling/unmarshalling

If you need those packages I'd recommend using client-go. There's no way to import kubernetes/api without getting most of the client-go package anyway.

I still think my earlier comment about a RawResource would be the way to handle this use case.

from k8s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.