Closed hexfusion closed 1 year ago
Using go bindings consume a pod spec and schedule a new pod. We will want to decode the file to v1.Pod so we can add what we want such as env, name etc before scheduling.
podman play kube pod.yaml
package main import ( "fmt" v1 "k8s.io/api/apps/v1" "k8s.io/client-go/kubernetes/scheme" ) var podYaml = ` apiVersion: v1 kind: Pod metadata: labels: app: demo-pod name: demo-pod spec: containers: - image: quay.io/libpod/alpine_nginx:latest name: demo ports: - containerPort: 80 hostPort: 8000 func main() { decode := scheme.Codecs.UniversalDeserializer().Decode obj, _, err := decode([]byte(podYamlBytes, nil, nil) if err != nil { fmt.Printf("%#v", err) } pod := obj.(*v1.Pod) fmt.Printf("%#v\n", pod) }
https://github.com/containers/podman/blob/main/pkg/bindings/kube/kube.go#L19
Using go bindings consume a pod spec and schedule a new pod. We will want to decode the file to v1.Pod so we can add what we want such as env, name etc before scheduling.
https://github.com/containers/podman/blob/main/pkg/bindings/kube/kube.go#L19