Documentation ¶
Index ¶
- Variables
- type ExecCommandRequest
- type KubernetesApiServiceImpl
- func (k *KubernetesApiServiceImpl) CreateRbac(ctx context.Context, serviceAccount *api_v1.ServiceAccount, ...) error
- func (k *KubernetesApiServiceImpl) CreateRuntimeClass(ctx context.Context, d *node_v1.RuntimeClass) error
- func (k *KubernetesApiServiceImpl) DeleteDaemonSet(ctx context.Context, d string, namespace string) error
- func (k *KubernetesApiServiceImpl) DeleteRbac() error
- func (k *KubernetesApiServiceImpl) DeleteRuntimeClass(s string) error
- func (k *KubernetesApiServiceImpl) DeployDaemonSet(ctx context.Context, d *apps_v1.DaemonSet) error
- func (k *KubernetesApiServiceImpl) ExecuteCommand(req ExecCommandRequest) (int, error)
- func (k *KubernetesApiServiceImpl) ExecuteVMCommand(req ExecCommandRequest) (int, error)
- func (k *KubernetesApiServiceImpl) GetKataDeployPod(p *api_v1.Pod) (*api_v1.Pod, error)
- func (k *KubernetesApiServiceImpl) GetKataDeployPods(labelSelector string, namespace string) ([]api_v1.Pod, error)
- func (k *KubernetesApiServiceImpl) GetPod(ctx context.Context, podName string, namespace string) (*api_v1.Pod, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ServiceAccount = &api_v1.ServiceAccount{ ObjectMeta: meta_v1.ObjectMeta{ Name: "kata-label-node", Namespace: "kube-system", }, } ClusterRole = &rbac.ClusterRole{ TypeMeta: meta_v1.TypeMeta{ Kind: "ClusterRole", APIVersion: "rbac.authorization.k8s.io/v1", }, ObjectMeta: meta_v1.ObjectMeta{ Name: "node-labeler", }, Rules: []rbac.PolicyRule{ { APIGroups: []string{""}, Resources: []string{"nodes"}, Verbs: []string{"get", "patch"}, }, }, } ClusterRoleBinding = &rbac.ClusterRoleBinding{ TypeMeta: meta_v1.TypeMeta{ Kind: "ClusterRoleBinding", APIVersion: "rbac.authorization.k8s.io/v1", }, ObjectMeta: meta_v1.ObjectMeta{ Name: "kata-label-node-rb", }, RoleRef: rbac.RoleRef{ APIGroup: rbac.GroupName, Kind: "ClusterRole", Name: "node-labeler", }, Subjects: []rbac.Subject{ { Kind: rbac.ServiceAccountKind, Namespace: "kube-system", Name: "kata-label-node", }, }, } DaemonSetDeployment = &apps_v1.DaemonSet{ ObjectMeta: meta_v1.ObjectMeta{ Name: "kata-deploy", Namespace: "kube-system", }, Spec: apps_v1.DaemonSetSpec{ Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "name": "kata-deploy", }, }, UpdateStrategy: apps_v1.DaemonSetUpdateStrategy{ Type: apps_v1.RollingUpdateDaemonSetStrategyType, RollingUpdate: nil, }, Template: api_v1.PodTemplateSpec{ ObjectMeta: meta_v1.ObjectMeta{ Labels: map[string]string{ "name": "kata-deploy", }, }, Spec: api_v1.PodSpec{ ServiceAccountName: "kata-label-node", Containers: []api_v1.Container{ { Name: "kube-kata", Image: "docker.io/tim12312/kata-deploy:latest", Command: []string{"bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh install"}, Env: []api_v1.EnvVar{ { Name: "NODE_NAME", ValueFrom: &api_v1.EnvVarSource{ FieldRef: &api_v1.ObjectFieldSelector{ FieldPath: "spec.nodeName", }, }, }, }, VolumeMounts: []api_v1.VolumeMount{ { Name: "crio-conf", MountPath: "/etc/crio/", }, { Name: "containerd-conf", MountPath: "/etc/containerd", }, { Name: "kata-artifacts", MountPath: "/opt/kata/", }, { Name: "dbus", MountPath: "/var/run/dbus", }, { Name: "run", MountPath: "/run", }, { Name: "local-bin", MountPath: "/usr/local/bin/", }, { Name: "log", MountPath: "/dev/log", }, }, Lifecycle: &api_v1.Lifecycle{ PreStop: &api_v1.LifecycleHandler{ Exec: &api_v1.ExecAction{ Command: []string{"bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh cleanup"}, }, }, }, ImagePullPolicy: api_v1.PullAlways, SecurityContext: &api_v1.SecurityContext{ Privileged: privileged(), }, }, }, Volumes: []api_v1.Volume{ { Name: "crio-conf", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/etc/crio/", }, }, }, { Name: "containerd-conf", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/etc/containerd/", }, }, }, { Name: "kata-artifacts", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/opt/kata/", Type: &hostPathDirectoryOrCreate, }, }, }, { Name: "dbus", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/var/run/dbus", }, }, }, { Name: "run", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/run", }, }, }, { Name: "local-bin", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/usr/local/bin/", }, }, }, { Name: "log", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/dev/log", Type: &hostPathSocket, }, }, }, }, }, }, }, } RuntimeClass = func(name string, cpu string, memory string) *node_v1.RuntimeClass { return &node_v1.RuntimeClass{ TypeMeta: meta_v1.TypeMeta{ Kind: "RuntimeClass", APIVersion: "node.k8s.io/v1", }, ObjectMeta: meta_v1.ObjectMeta{ Name: name, }, Handler: name, Overhead: &node_v1.Overhead{ PodFixed: map[api_v1.ResourceName]resource.Quantity{ api_v1.ResourceCPU: resource.MustParse(cpu), api_v1.ResourceMemory: resource.MustParse(memory), }, }, Scheduling: &node_v1.Scheduling{ NodeSelector: map[string]string{ "katacontainers.io/kata-runtime": "true", }, }, } } DaemonSetCleanDeployment = &apps_v1.DaemonSet{ ObjectMeta: meta_v1.ObjectMeta{ Name: "kubelet-kata-cleanup", Namespace: "kube-system", }, Spec: apps_v1.DaemonSetSpec{ Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "name": "kubelet-kata-cleanup", }, }, UpdateStrategy: apps_v1.DaemonSetUpdateStrategy{ Type: apps_v1.RollingUpdateDaemonSetStrategyType, RollingUpdate: &apps_v1.RollingUpdateDaemonSet{ MaxUnavailable: &intstr.IntOrString{ Type: 0, IntVal: 1, }, }, }, Template: api_v1.PodTemplateSpec{ ObjectMeta: meta_v1.ObjectMeta{ Labels: map[string]string{ "name": "kubelet-kata-cleanup", }, }, Spec: api_v1.PodSpec{ ServiceAccountName: "kata-label-node", Containers: []api_v1.Container{ { Name: "kube-kata", Image: "docker.io/tim12312/kata-deploy:latest", Command: []string{"/bin/sh"}, Args: []string{"-c", "sleep 500"}, Env: []api_v1.EnvVar{ { Name: "NODE_NAME", ValueFrom: &api_v1.EnvVarSource{ FieldRef: &api_v1.ObjectFieldSelector{ FieldPath: "spec.nodeName", }, }, }, }, VolumeMounts: []api_v1.VolumeMount{ { Name: "dbus", MountPath: "/var/run/dbus", }, { Name: "systemd", MountPath: "/run/systemd", }, }, ImagePullPolicy: api_v1.PullAlways, SecurityContext: &api_v1.SecurityContext{ Privileged: privileged(), }, }, }, Volumes: []api_v1.Volume{ { Name: "dbus", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/var/run/dbus", }, }, }, { Name: "systemd", VolumeSource: api_v1.VolumeSource{ HostPath: &api_v1.HostPathVolumeSource{ Path: "/run/systemd", }, }, }, }, }, }, }, } )
View Source
var KubernetesConfigFlags = genericclioptions.NewConfigFlags(true)
Functions ¶
This section is empty.
Types ¶
type ExecCommandRequest ¶
type KubernetesApiServiceImpl ¶
type KubernetesApiServiceImpl struct {
// contains filtered or unexported fields
}
func NewKubernetesApiServiceImpl ¶
func NewKubernetesApiServiceImpl() (k *KubernetesApiServiceImpl, err error)
func (*KubernetesApiServiceImpl) CreateRbac ¶
func (k *KubernetesApiServiceImpl) CreateRbac(ctx context.Context, serviceAccount *api_v1.ServiceAccount, clusterRole *rbac.ClusterRole, clusterRoleBinding *rbac.ClusterRoleBinding) error
func (*KubernetesApiServiceImpl) CreateRuntimeClass ¶
func (k *KubernetesApiServiceImpl) CreateRuntimeClass(ctx context.Context, d *node_v1.RuntimeClass) error
func (*KubernetesApiServiceImpl) DeleteDaemonSet ¶
func (*KubernetesApiServiceImpl) DeleteRbac ¶
func (k *KubernetesApiServiceImpl) DeleteRbac() error
func (*KubernetesApiServiceImpl) DeleteRuntimeClass ¶
func (k *KubernetesApiServiceImpl) DeleteRuntimeClass(s string) error
func (*KubernetesApiServiceImpl) DeployDaemonSet ¶
func (*KubernetesApiServiceImpl) ExecuteCommand ¶
func (k *KubernetesApiServiceImpl) ExecuteCommand(req ExecCommandRequest) (int, error)
func (*KubernetesApiServiceImpl) ExecuteVMCommand ¶
func (k *KubernetesApiServiceImpl) ExecuteVMCommand(req ExecCommandRequest) (int, error)
func (*KubernetesApiServiceImpl) GetKataDeployPod ¶
func (*KubernetesApiServiceImpl) GetKataDeployPods ¶
Click to show internal directories.
Click to hide internal directories.