huawei

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

README

Huawei CCI

Huawei CCI (Cloud Container Instance) service provides serverless container management, and does not require users to manage the cluster and the server. Only through simple configuration, users can enjoy the agility and high performance of the container. CCI supports stateless workloads (Deployment) and stateful workload (StatefulSet). On the basis of Kubernetes, we have made a series of important enhancements such as secure container, elastic load balancing, elastic scalability, Blue Green Deployment and so on.

Huawei CCI Virtual Kubelet Provider

Huawei CCI virtual kubelet provider configures a CCI project as node in any of your Kubernetes cluster, such as Huawei CCE (Cloud Container Engine). CCE supports native Kubernetes applications and tools as private cluster, allowing you to easily set up a container runtime environment. Pod which is scheduled to the virtual kubelet provider will run in the CCI, that will makes good use of the high performance of CCI. The diagram below illustrates how Huawei CCI virtual kubelet provider works.

diagram

NOTE: The Huawei CCI virtual-kubelet provider is in the early stages of development, and don't use it in a production environment.

Prerequisites

You must install the provider in a Kubernetes cluster and connect to the CCI, and also need create an account for CCI. Once you've created your account, then need to record the aksk, region for the configuration in next step.

Configuration

Before run CCI Virtual Kubelet Provider, you must do as the following steps.

  1. Create a configuration profile. You need to provide the fields you specify like in the example fils.
  2. Copy your AKSK and save them in environment variable:
export APP_KEY="<AppKey>"
export APP_SECRET="<AppSecret>"

Connect to CCI from your cluster via Virtual Kubelet

On the Kubernetes work node, starting a virtual-kubelet process as follows.

virtual-kubelet --provider huawei --provider-config cci.toml

Then run kubectl get nodes in your cluster to validate the provider has been running as a node.

kubectl get nodes
NAME                            STATUS       AGE       
virtual-kubelet                 Ready        5m        
cce-192.168.0.178               Ready        10d       
cce-192.168.0.233               Ready        10d      

If want to stop the virtual kubelet, just stop the virtual kubelet process.

Schedule pod to CCI via Virtual Kubelet

apiVersion: v1
kind: Pod
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  nodeName: virtual-kubelet
  containers:
  - name: nginx
    image: 1and1internet/ubuntu-16-nginx
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 8080
  tolerations:
  - key: huawei.com/cci
    effect: NoSchedule

Replace the nodeName to the virtual-kubelet nodename and save the configuration to a file virtual-kubelet-pod.yaml. Then run kubectl create -f virtual-kubelet-pod.yaml to create the pod. Run kubectl get pods -owide to get pods.

kubectl get pods -o wide
NAME                                            READY     STATUS    RESTARTS   AGE       IP             NODE
myapp-7c7877989-vbffm                           1/1       Running   0          39s       172.17.0.3     virtual-kubelet

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CCIMock

type CCIMock struct {
	OnCreateProject func(*v1.Namespace) (int, interface{})
	OnCreatePod     func(*v1.Pod) (int, interface{})
	OnGetPods       func() (int, interface{})
	OnGetPod        func(string, string) (int, interface{})
	// contains filtered or unexported fields
}

CCIMock implements a CCI service mock server.

func NewCCIMock

func NewCCIMock() *CCIMock

NewCCIMock creates a CCI service mock server.

func (*CCIMock) Close

func (mock *CCIMock) Close()

Close terminates the CCI mock server.

func (*CCIMock) GetServerURL

func (mock *CCIMock) GetServerURL() string

GetServerURL returns the mock server URL.

type CCIProvider

type CCIProvider struct {
	// contains filtered or unexported fields
}

CCIProvider implements the virtual-kubelet provider interface and communicates with Huawei's CCI APIs.

func NewCCIProvider

func NewCCIProvider(config string, rm *manager.ResourceManager, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*CCIProvider, error)

NewCCIProvider creates a new CCI provider.

func (*CCIProvider) Capacity

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

Capacity returns a resource list with the capacity constraints of the huawei CCI provider.

func (*CCIProvider) CreatePod

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

CreatePod takes a Kubernetes Pod and deploys it within the huawei CCI provider.

func (*CCIProvider) DeletePod

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

DeletePod takes a Kubernetes Pod and deletes it from the huawei CCI provider.

func (*CCIProvider) ExecInContainer

func (p *CCIProvider) ExecInContainer(name string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error

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

func (*CCIProvider) GetContainerLogs

func (p *CCIProvider) GetContainerLogs(ctx context.Context, namespace, podName, containerName string, tail int) (string, error)

GetContainerLogs retrieves the logs of a container by name from the huawei CCI provider.

func (*CCIProvider) GetPod

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

GetPod retrieves a pod by name from the huawei CCI provider.

func (*CCIProvider) GetPodFullName

func (p *CCIProvider) GetPodFullName(namespace string, pod string) string

Get full pod name as defined in the provider context TODO: Implementation

func (*CCIProvider) GetPodStatus

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

GetPodStatus retrieves the status of a pod by name from the huawei CCI provider.

func (*CCIProvider) GetPods

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

GetPods retrieves a list of all pods running on the huawei CCI provider.

func (*CCIProvider) NodeAddresses

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

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

func (*CCIProvider) NodeConditions

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

NodeConditions returns a list of conditions (Ready, OutOfDisk, etc), which is polled periodically to update the node status within Kubernetes.

func (*CCIProvider) NodeDaemonEndpoints

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

NodeDaemonEndpoints returns NodeDaemonEndpoints for the node status within Kubernetes.

func (*CCIProvider) OperatingSystem

func (p *CCIProvider) OperatingSystem() string

OperatingSystem returns the operating system the huawei CCI provider is for.

func (*CCIProvider) UpdatePod

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

UpdatePod takes a Kubernetes Pod and updates it within the huawei CCI provider.

type Client

type Client struct {
	Signer     auth.Signer
	HTTPClient http.Client
}

Client represents the client config for Huawei.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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