123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package prebind
- import (
- "context"
- "fmt"
- v1 "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/runtime"
- framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
- )
- type StatelessPreBindExample struct{}
- var _ framework.PreBindPlugin = StatelessPreBindExample{}
- const Name = "stateless-prebind-plugin-example"
- func (sr StatelessPreBindExample) Name() string {
- return Name
- }
- func (sr StatelessPreBindExample) PreBind(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) *framework.Status {
- if pod == nil {
- return framework.NewStatus(framework.Error, fmt.Sprintf("pod cannot be nil"))
- }
- if pod.Namespace != "foo" {
- return framework.NewStatus(framework.Unschedulable, "only pods from 'foo' namespace are allowed")
- }
- return nil
- }
- func New(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
- return &StatelessPreBindExample{}, nil
- }
|