Skip to content

Instantly share code, notes, and snippets.

@kozikow
Last active November 20, 2016 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kozikow/e7952b9560c97454d5816ea94d470c09 to your computer and use it in GitHub Desktop.
Save kozikow/e7952b9560c97454d5816ea94d470c09 to your computer and use it in GitHub Desktop.
Prototype generating config from go code
package main
import (
"os"
"k8s.io/client-go/1.4/pkg/api"
"k8s.io/client-go/1.4/pkg/runtime/serializer/json"
"k8s.io/client-go/1.4/pkg/util/intstr"
)
func main() {
service := &api.Service{Spec: api.ServiceSpec{Ports: []api.ServicePort{{
Protocol: "TCP",
Port: 12346,
TargetPort: intstr.FromInt(12346),
}}}}
e := json.NewYAMLSerializer(json.DefaultMetaFactory, nil, nil)
err := e.Encode(service, os.Stdout)
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment