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

experiment: schedule pod with pod.yaml #4

Closed
hexfusion opened this issue Jun 22, 2023 · 0 comments
Closed

experiment: schedule pod with pod.yaml #4

hexfusion opened this issue Jun 22, 2023 · 0 comments
Assignees
Milestone

Comments

@hexfusion
Copy link
Owner

hexfusion commented Jun 22, 2023

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

@hexfusion hexfusion added this to the MVP milestone Jun 22, 2023
@hexfusion hexfusion moved this to Todo in Hackathon 2023 Jun 22, 2023
@hexfusion hexfusion changed the title experiment: create pod with pod.yaml experiment: schedule pod with pod.yaml Jun 22, 2023
@hexfusion hexfusion self-assigned this Jun 22, 2023
@hexfusion hexfusion moved this from Todo to In Progress in Hackathon 2023 Jun 22, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Hackathon 2023 Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant