openstack

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

README

OpenStack Zun

OpenStack Zun is an OpenStack Container service. It aims to provide an API service for running application containers without the need to manage servers or clusters.

OpenStack Zun virtual-kubelet provider

OpenStack Zun virtual-kubelet provider connects your Kubernetes cluster to an OpenStack Cloud. Your pods on OpenStack have access to OpenStack tenant networks since each pod is given dedicated Neutron ports in your tenant subnets.

Prerequisites

You need to have an OpenStack cloud with Zun service installed. The quickest way to get everything setup is using Devstack. If it is for production purpose, you follow the Zun installation guide. Another alternative is using Kolla.

Authentication via Keystone

Virtual-kubelet needs permission to schedule pods on OpenStack Zun on your behalf. You will need to retrieve your OpenStack credentials and store them as environment variables.

export OS_DOMAIN_ID=default
export OS_REGION_NAME=RegionOne
export OS_PROJECT_NAME=demo
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL=http://10.0.2.15/identity/v3
export OS_USERNAME=demo
export OS_PASSWORD=password

For users that have the OpenStack dashboard installed, there's a shortcut. If you visit the project/access_and_security path in Horizon and click on the "Download OpenStack RC File" button at the top right hand corner, you will download a bash file that exports all of your access details to environment variables. To execute the file, run source admin-openrc.sh and you will be prompted for your password.

Connecting virtual-kubelet to your Kubernetes cluster

Start the virtual-kubelet process.

virtual-kubelet --provider openstack

In your Kubernetes cluster, confirm that the virtual-kubelet shows up as a node.

kubectl get nodes

NAME              STATUS     ROLES    AGE   VERSION
virtual-kubelet   Ready      agent    20d   v1.13.1-vk-N/A
...

To disconnect, stop the virtual-kubelet process.

Deploying Kubernetes pods in OpenStack Zun

In order to not break existing pod deployments, the OpenStack virtual node is given a taint. Pods that are to be deployed on OpenStack require an explicit toleration that tolerates the taint of the virtual node.

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  tolerations:
  - key: "virtual-kubelet.io/provider"
    operator: "Equal"
    value: "openstack"
    effect: "NoSchedule"
  containers:
  - name: myapp-container
    image: busybox
    command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CapsuleSpec

type CapsuleSpec struct {
	Volumes       []Volume    `json:"volumes,omitempty"`
	Containers    []Container `json:"containers,omitempty"`
	RestartPolicy string      `json:"restartPolicy,omitempty"`
}

CapsuleSpec

type CapsuleTemplate

type CapsuleTemplate struct {
	Spec     CapsuleSpec `json:"spec,omitempty"`
	Kind     string      `json:"kind,omitempty"`
	Metadata Metadata    `json:"metadata,omitempty"`
}

type Container

type Container struct {
	//	Name    string `json:"name" protobuf:"bytes,1,opt,name=name"`
	Image      string   `json:"image,omitempty" protobuf:"bytes,2,opt,name=image"`
	Command    []string `json:"command,omitempty" protobuf:"bytes,3,rep,name=command"`
	Args       []string `json:"args,omitempty" protobuf:"bytes,4,rep,name=args"`
	WorkingDir string   `json:"workDir,omitempty" protobuf:"bytes,5,opt,name=workingDir"`
	//	Ports   []ContainerPort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"containerPort" protobuf:"bytes,6,rep,name=ports"`
	Env map[string]string `json:"env,omitempty"`
	//ENV is different with Kubernetes
	//	Env     []EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,6,rep,name=env"`
	Resources ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,7,opt,name=resources"`
	//	VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" patchStrategy:"merge" patchMergeKey:"mountPath" protobuf:"bytes,8,rep,name=volumeMounts"`
	ImagePullPolicy string `json:"imagePullPolicy,omitempty" protobuf:"bytes,8,opt,name=imagePullPolicy"`
}

type Metadata

type Metadata struct {
	Labels map[string]string `json:"labels,omitempty"`
	Name   string            `json:"name,omitempty"`
}

type ResourceList

type ResourceList map[ResourceName]float64

type ResourceName

type ResourceName string

type ResourceRequirements

type ResourceRequirements struct {
	Limits ResourceList `json:"requests,omitempty" protobuf:"bytes,1,rep,name=limits"`
}

ResourceRequirements describes the compute resource requirements.

type Volume

type Volume struct {
	Name string `json:"name,omitempty"`
}

type ZunProvider

type ZunProvider struct {
	ZunClient *gophercloud.ServiceClient
	// contains filtered or unexported fields
}

ZunProvider implements the virtual-kubelet provider interface and communicates with OpenStack's Zun APIs.

func NewZunProvider

func NewZunProvider(config string, rm *manager.ResourceManager, nodeName string, operatingSystem string, daemonEndpointPort int32) (*ZunProvider, error)

NewZunProvider creates a new ZunProvider.

func (*ZunProvider) Capacity

func (p *ZunProvider) Capacity(ctx context.Context) v1.ResourceList

Capacity returns a resource list containing the capacity limits set for Zun.

func (*ZunProvider) CreatePod

func (p *ZunProvider) CreatePod(ctx context.Context, pod *v1.Pod) error

CreatePod accepts a Pod definition and creates an Zun deployment

func (*ZunProvider) DeletePod

func (p *ZunProvider) DeletePod(ctx context.Context, pod *v1.Pod) error

DeletePod deletes the specified pod out of Zun.

func (*ZunProvider) GetContainerLogs

func (p *ZunProvider) GetContainerLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error)

func (*ZunProvider) GetPod

func (p *ZunProvider) GetPod(ctx context.Context, namespace, name string) (*v1.Pod, error)

GetPod returns a pod by name that is running inside Zun returns nil if a pod by that name is not found.

func (*ZunProvider) GetPodStatus

func (p *ZunProvider) GetPodStatus(ctx context.Context, namespace, name string) (*v1.PodStatus, error)

GetPodStatus returns the status of a pod by name that is running inside Zun returns nil if a pod by that name is not found.

func (*ZunProvider) GetPods

func (p *ZunProvider) GetPods(ctx context.Context) ([]*v1.Pod, error)

GetPods returns a list of all pods known to be running within Zun.

func (*ZunProvider) NodeAddresses

func (p *ZunProvider) NodeAddresses(ctx context.Context) []v1.NodeAddress

NodeAddresses returns a list of addresses for the node status within Kubernetes.

func (*ZunProvider) NodeConditions

func (p *ZunProvider) NodeConditions(ctx context.Context) []v1.NodeCondition

NodeConditions returns a list of conditions (Ready, OutOfDisk, etc), for updates to the node status within Kubernetes.

func (*ZunProvider) NodeDaemonEndpoints

func (p *ZunProvider) NodeDaemonEndpoints(ctx context.Context) *v1.NodeDaemonEndpoints

NodeDaemonEndpoints returns NodeDaemonEndpoints for the node status within Kubernetes.

func (*ZunProvider) OperatingSystem

func (p *ZunProvider) OperatingSystem() string

OperatingSystem returns the operating system for this provider. This is a noop to default to Linux for now.

func (*ZunProvider) RunInContainer added in v0.10.0

func (p *ZunProvider) RunInContainer(ctx context.Context, namespace, name, container string, cmd []string, attach api.AttachIO) error

RunInContainer executes a command in a container in the pod, copying data between in/out/err and the container's stdin/stdout/stderr.

func (*ZunProvider) UpdatePod

func (p *ZunProvider) UpdatePod(ctx context.Context, pod *v1.Pod) error

UpdatePod is a noop, Zun currently does not support live updates of a pod.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL