beku

package module
v0.0.0-...-fcb9519 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 19 Imported by: 1

README

Beku

GoDoc Go Report Card

Beku is an extremely user-friendly Kubernetes API resources building library, extremely easy without any extra intelligence.

Installation
go get -u github.com/yulibaozi/beku
RoadMap

RoadMap

Features
  • Auto release resource object on Kubernetes
  • Flexible custom development
  • Extremely simple JSON & YAML input / output
  • Required Kubernetes API resources fields automatically confirming
  • Interrelated Kubernetes API resources announcement which is so user-friendly
  • Rigorous QOS setup
  • Precise fileds auto-fillment
  • Graceful chain methods and invocation
Document
Introduction

Due to the complexities of Kubernetes API resources configuration, miscellaneous fields, diverse hierarchies, rehandling over and over again, Beku was inspirationally born.

The scenario of Beku is to matching Kubernetes Client-go, and providing json / yaml file for CLI creation. It's very appreciative and helpful that Beku has use Kubernetes codes for reference.

caas-one
Beku-style Usage
  1. Chain methods starts with NewXXX() and end up with Finish(), then we could get whole Kubernetes API resource configuration.
  2. All setup methods starts with SetXXX() and all retrieves starts with GetXXX().
  3. Don't use type cast to satisfying the type needed by some functions as far as possible, it may leads to uncertain errors.
  4. There are comments of the usage of some function parameters if you don't know how to handle it.
  5. There is a PRESUPPOSE that the first container in Pod has higher status, which will have setup priority. The latter in the sequence of containers, the lower status it has. E.g: Beku will only set the first container's environments when we first invoke the setup function, the next time we invoke it will set the next container.
  6. If there is union in some struct definition, it means two Kubernetes API resource will be created simultaneously. E.g: Deployment, Service union, PersistentVolume, PersistentVolumeClain union.
Examples

How to create a Service(svc) in few seconds?

As you will see:

func howToNewSvc() {
	svc, err := beku.NewSvc().SetNamespaceAndName("roc", "mysql-svc").
		SetSelector(map[string]string{"app": "mysql"}).SetServiceType(beku.ServiceTypeNodePort).
		SetPort(beku.ServicePort{Port: 3306, TargetPort: 3306}).Finish()
	if err != nil {
		panic(err)
	}
	yamlbyts, err := beku.ToYAML(svc)
	jsonbyts, err := beku.ToJSON(svc)
	if err != nil {
		panic(err)
	}

}

ToYAML

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  name: mysql-svc
  namespace: roc
spec:
  ports:
  - port: 3306
    protocol: TCP
    targetPort: 3306
  selector:
    app: mysql
  type: NodePort
status:
  loadBalancer: {}

ToJSON

{
    "kind":"Service",
    "apiVersion":"v1",
    "metadata":
    {
        "name":"mysql-svc",
        "namespace":"roc",
        "creationTimestamp":null
    },
    "spec":
    {
        "ports":
        [
            {
                "protocol":"TCP",
                "port":3306,
                "targetPort":3306
            }
        ],
        "selector":
        {
            "app":"mysql"
        },
        "type":"NodePort"
    },
    "status":
    {
        "loadBalancer":{}
    }
}

More examples: Example.md

Currently supported Kubernetes API resources in Beku
Kubernetes API resources Abbreviation Version
namespace ns core/v1
service svc core/v1
deployment - apps/v1
statefulset sts apps/v1
secret - core/v1
persistentVolumeClaim pvc core/v1
persistentVolume pv core/v1
daemonSet ds apps/v1
configMap cm core/v1
storageClass - storage.k8s.io/v1
pod - core/v1
priorityClass - scheduling.k8s.io/v1beta1
clusterRole - rbac.authorization.k8s.io/v1beta1
clusterRoleBinding - rbac.authorization.k8s.io/v1beta1
serviceAccount sa v1
node - v1
Beku Implementation Strategy
  1. Only one API resource version will be implemented even it has multi versions. Since stability instead of diversity is the first place concern, which may lead some lags to the latest version. But it won't be a problem. On the other hand, below are priorities when choosing API resource version:

    • core/v1
    • apps/v1 ...
  2. When implementing Kubernetes API resource objects which lack of stable version, Alpha versions will not be implemented. Because less stable versions have more probablities to be changed.

  3. Kubernetes API resource versions references: Kubernetes API Introduction

Beku Conception

In the past, I found that it's pretty tedious to write Kubernetes API reosurces configuration, besides the complexity of configurable fields, there still need extra intelligence like:

  • It's a problem that configurable fields which is required or optional.
  • Kubernetes API resources have diverse hierarchies, it's a problem the localtions of configurable fields in json/yaml file.
  • Indentation need to taken in to consideration when writing yaml file.
  • It's a problem that those issues above happen over and over again.

There are drawbacks in current implementations, e.g. we implemented the general fill of some fields in one Kubernetes API resource instead of the complex way, this may lead multi advanced fill strategies not available. You could propose a PR or issue for disscution. On the other hand, there are still some capabilities need to be completed, we could work together.

In the future, expected to eliminate the 3 drawbacks above and make a progress to the targets below:

  • Invoker provide required fields, non-need fields don't fill.
  • Invoker provide non-hierachy fields, extra intelliengcy burden exliminated.
  • Invoker provide requreid fields to make complete json/yaml configuration.
  • Invoker provide single field, other related fields will be filled automatically.
  • Invoker provide incomplete fields, Beku will return lacked fields helping invokers to accomplish fill.

Documentation

Index

Constants

View Source
const (
	BestEffortRank = iota
	BurstableRank
	GuaranteedRank
)

qos rank,the higher the number, the higher the level

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(src string) ([]byte, error)

Base64Decode base64 decode

func Base64Encode

func Base64Encode(src []byte) string

Base64Encode base64 encode

func DaemonSetToSvc

func DaemonSetToSvc(ds *appsv1.DaemonSet, sty ServiceType, autoRelease ...bool) (*v1.Service, error)

DaemonSetToSvc Use the Set to generate the associated SVC autoRelease[0] if true,beku will auto Release Service On Kubernetes,default can't Release Service On Kubernetes

func DeploymentToSvc

func DeploymentToSvc(dp *appsv1.Deployment, sty ServiceType, autoRelease ...bool) (*v1.Service, error)

DeploymentToSvc Use the Deployment to generate the associated SVC autoRelease[0] if true,beku will auto Release Service On Kubernetes,default can't Release Service On Kubernetes

func FromInt

func FromInt(val int) intstr.IntOrString

FromInt creates an IntOrString object with an int32 value. It is your responsibility not to call this method with a value greater than int32. TODO: convert to (val int32)

func FromString

func FromString(val string) intstr.IntOrString

FromString creates an IntOrString object with a string value.

func GetKubeClient

func GetKubeClient(isInCluster ...bool) (*kubernetes.Clientset, error)

GetKubeClient get Kubernetes apiServer

func GetPodQOS

func GetPodQOS(pod v1.PodSpec) v1.PodQOSClass

GetPodQOS returns the QoS class of a pod. A pod is besteffort if none of its containers have specified any requests or limits. A pod is guaranteed only when requests and limits are specified for all the containers and they are equal. A pod is burstable if limits and requests do not match across all containers.

func JSONToYAML

func JSONToYAML(jbyts []byte) (ybyts []byte, err error)

JSONToYAML json data translate into yaml

func MapsToResources

func MapsToResources(resources map[string]string) map[ResourceName]string

MapsToResources string type resource object to beku resource resource object

func Parse

func Parse(val string) intstr.IntOrString

Parse the given string and try to convert it to an integer before setting it as a string value.

func RegisterK8sClient

func RegisterK8sClient(host, ca, cert, key string) error

RegisterK8sClient register k8s apiServer Client on Beku If the certificate is not required, ca,cert,key field is ""

func RegisterK8sClientBase64

func RegisterK8sClientBase64(host, ca, cert, key string) error

RegisterK8sClientBase64 register k8s apiServer Client on Beku use the function when ca,cert,key were base64 encode. the function will base64 decode ca,cert,key ca is certificate-authority-data cert is client-certificate-data key is client-key-data

func RegisterResourceLimit

func RegisterResourceLimit(limits map[ResourceName]string) error

RegisterResourceLimit register you need default resource limit, resource only include CPU and MEMORY

func RegisterResourceRequest

func RegisterResourceRequest(request map[ResourceName]string) error

RegisterResourceRequest register you need default resource limit, resource only include CPU and MEMORY

func ResourceMapsToK8s

func ResourceMapsToK8s(maps map[ResourceName]string) (v1.ResourceList, error)

ResourceMapsToK8s to K8s resourceList

func StatefulSetToSvc

func StatefulSetToSvc(sts *appsv1.StatefulSet, sty ServiceType, isHeadless bool, autoRelease ...bool) (*v1.Service, error)

StatefulSetToSvc Use the StatefulSet to generate the associated SVC autoRelease[0] if true,beku will auto Release Service On Kubernetes,default can't Release Service On Kubernetes

func ToJSON

func ToJSON(v interface{}) (byts []byte, err error)

ToJSON struct translate into json

func ToYAML

func ToYAML(o interface{}) (byts []byte, err error)

ToYAML struct translate into yaml

func ViaTLS

func ViaTLS(ca, cert, key []byte) bool

ViaTLS verify Kubernetes apiServer cert

func YAMLToJSON

func YAMLToJSON(ybyts []byte) (jbyts []byte, err error)

YAMLToJSON yaml data translate into json

Types

type CephFSPersistentVolumeSource

type CephFSPersistentVolumeSource struct {
	// Required: Monitors is a collection of Ceph monitors
	// More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it
	Monitors []string `json:"monitors" protobuf:"bytes,1,rep,name=monitors"`
	// Optional: Used as the mounted root, rather than the full Ceph tree, default is /
	// +optional
	Path string `json:"path,omitempty" protobuf:"bytes,2,opt,name=path"`
	// Optional: User is the rados user name, default is admin
	// More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it
	// +optional
	User string `json:"user,omitempty" protobuf:"bytes,3,opt,name=user"`
	// Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret
	// More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it
	// +optional
	SecretFile string `json:"secretFile,omitempty" protobuf:"bytes,4,opt,name=secretFile"`
	// Optional: SecretRef is reference to the authentication secret for User, default is empty.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it
	// +optional
	SecretRef *SecretReference `json:"secretRef,omitempty" protobuf:"bytes,5,opt,name=secretRef"`
	// Optional: Defaults to false (read/write). ReadOnly here will force
	// the ReadOnly setting in VolumeMounts.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it
	// +optional
	ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,6,opt,name=readOnly"`
}

CephFSPersistentVolumeSource ceph volume setting

type ClusterRole

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

ClusterRole include kubernetes resource object ClusterRole and error

func NewClusterRole

func NewClusterRole() *ClusterRole

NewClusterRole create ClusterRole and chain function call begin with this function.

func (*ClusterRole) Finish

func (obj *ClusterRole) Finish() (*v1beta1.ClusterRole, error)

Finish Chain function call end with this function return Kubernetes resource object ClusterRole and error. In the function, it will check necessary parameters、input the default field。

func (*ClusterRole) JSONNew

func (obj *ClusterRole) JSONNew(jsonbyts []byte) *ClusterRole

JSONNew use json data create ClusterRole

func (*ClusterRole) SetName

func (obj *ClusterRole) SetName(name string) *ClusterRole

SetName set ClusterRole name

func (*ClusterRole) SetRole

func (obj *ClusterRole) SetRole(verbs, apiGroups, resources []string) *ClusterRole

SetRole set cluster role verbs is func method. such as "get", "watch", "list","create", "delete" ..., you can set "*" if you want to use all the func method apiGroups is resource apiGroup. such as "v1", "apps/v1", "rbac.authorization.k8s.io"... , you can set "*" if you want to use all the resource apiGroup resources is resources object. such as "daemonsets", "deployments","replicasets", you can set "*" if you want to use all the resource object.

func (*ClusterRole) YAMLNew

func (obj *ClusterRole) YAMLNew(yamlbyts []byte) *ClusterRole

YAMLNew use yaml data create ClusterRole

type ClusterRoleBinding

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

ClusterRoleBinding include kubernetes resource object ClusterRoleBinding and error

func NewClusterRoleBinding

func NewClusterRoleBinding() *ClusterRoleBinding

NewClusterRoleBinding create NewClusterRoleBinding and chain function call begin with this function.

func (*ClusterRoleBinding) Finish

Finish Chain function call end with this function return Kubernetes resource object ClusterRoleBinding and error. In the function, it will check necessary parameters、input the default field。

func (*ClusterRoleBinding) JSONNew

func (obj *ClusterRoleBinding) JSONNew(jsonbyts []byte) *ClusterRoleBinding

JSONNew use json data create ClusterRoleBinding

func (*ClusterRoleBinding) SetName

func (obj *ClusterRoleBinding) SetName(name string) *ClusterRoleBinding

SetName set ClusterRoleBinding name

func (*ClusterRoleBinding) SetRoleRef

func (obj *ClusterRoleBinding) SetRoleRef(name string) *ClusterRoleBinding

SetRoleRef set ClusterRoleBinding RoleRef

func (*ClusterRoleBinding) Subject

func (obj *ClusterRoleBinding) Subject(name string, kind SubKind, namespace string) *ClusterRoleBinding

Subject set ClusterRoleBinding subject kind only support "User", "Group", "ServiceAccount" namespace it is Required when kind is "ServiceAccount" default is "". it is Optional when kind is "User" or "Group"

func (*ClusterRoleBinding) YAMLNew

func (obj *ClusterRoleBinding) YAMLNew(yamlbyts []byte) *ClusterRoleBinding

YAMLNew use yaml data create ClusterRoleBinding

type ConfigMap

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

ConfigMap include Kubernetes resource object ConfigMap(cm) and error.

func NewCM

func NewCM() *ConfigMap

NewCM create ConfigMap(cm) and chain function call begin with this function.

func (*ConfigMap) Apply

func (obj *ConfigMap) Apply() (*v1.ConfigMap, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*ConfigMap) Finish

func (obj *ConfigMap) Finish() (cm *v1.ConfigMap, err error)

Finish chain function call end with this function return real ConfigMap(really ConfigMap is Kubernetes resource object ConfigMap(cm) and error) In the function, it will check necessary parameters、input the default field。

func (*ConfigMap) JSONNew

func (obj *ConfigMap) JSONNew(jsonbyts []byte) *ConfigMap

JSONNew use json data create ConfigMap

func (*ConfigMap) Release

func (obj *ConfigMap) Release() (*v1.ConfigMap, error)

Release release ConfigMap on Kubernetes

func (*ConfigMap) Replace

func (obj *ConfigMap) Replace(cm *v1.ConfigMap) *ConfigMap

Replace replace cm by Kubernetes resource object

func (*ConfigMap) SetData

func (obj *ConfigMap) SetData(data map[string]string) *ConfigMap

SetData set ConfigMap(cm) data, map[key]value

func (*ConfigMap) SetLabels

func (obj *ConfigMap) SetLabels(labels map[string]string) *ConfigMap

SetLabels set ConfigMap(cm) labels

func (*ConfigMap) SetName

func (obj *ConfigMap) SetName(name string) *ConfigMap

SetName set ConfigMap(cm) name

func (*ConfigMap) SetNamespace

func (obj *ConfigMap) SetNamespace(namespace string) *ConfigMap

SetNamespace set CofigMap(cm) namespace, default namespace value is 'dafault'

func (*ConfigMap) SetNamespaceAndName

func (obj *ConfigMap) SetNamespaceAndName(namespace, name string) *ConfigMap

SetNamespaceAndName set ConfigMap(cm) namespace and name

func (*ConfigMap) YAMLNew

func (obj *ConfigMap) YAMLNew(yamlbyts []byte) *ConfigMap

YAMLNew use yaml data create ConfigMap

type DaemonSet

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

DaemonSet include Kubernets resource object DaemonSet and error

func NewDS

func NewDS() *DaemonSet

NewDS create DaemonSet(ds) and chain function call begin with this function.

func (*DaemonSet) Apply

func (obj *DaemonSet) Apply() (*v1.DaemonSet, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*DaemonSet) Finish

func (obj *DaemonSet) Finish() (*v1.DaemonSet, error)

Finish Chain function call end with this function return real DaemonSet(really DaemonSet is kubernetes resource object DaemonSet and error In the function, it will check necessary parameters、input the default field

func (*DaemonSet) GetPodLabel

func (obj *DaemonSet) GetPodLabel() map[string]string

GetPodLabel get pod labels

func (*DaemonSet) ImagePullPolicy

func (obj *DaemonSet) ImagePullPolicy(pullPolicy PullPolicy) *DaemonSet

ImagePullPolicy DaemonSet pull image policy:Always,Never,IfNotPresent

func (*DaemonSet) JSONNew

func (obj *DaemonSet) JSONNew(jsonbyts []byte) *DaemonSet

JSONNew use json data create DaemonSet

func (*DaemonSet) Release

func (obj *DaemonSet) Release() (*v1.DaemonSet, error)

Release release DaemonSet on Kubernetes

func (*DaemonSet) Replace

func (obj *DaemonSet) Replace(ds *v1.DaemonSet) *DaemonSet

Replace replace ds by Kubernetes resource object

func (*DaemonSet) SetAnnotations

func (obj *DaemonSet) SetAnnotations(annotations map[string]string) *DaemonSet

SetAnnotations set DaemonSet annotations

func (*DaemonSet) SetCMDLiveness

func (obj *DaemonSet) SetCMDLiveness(cmd []string, initDelaySec, timeoutSec, periodSec int32) *DaemonSet

SetCMDLiveness set container liveness of cmd style cmd: execute liveness probe as commond line timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*DaemonSet) SetCMDReadness

func (obj *DaemonSet) SetCMDReadness(cmd []string, initDelaySec, timeoutSec, periodSec int32) *DaemonSet

SetCMDReadness set container readness of cmd style cmd: execute readness probe as commond line timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*DaemonSet) SetContainer

func (obj *DaemonSet) SetContainer(name, image string, containerPort int32) *DaemonSet

SetContainer set DaemonSet container name Not required when only one Container,you can input "". when many container this Field is necessary and cann't repeat image is necessary, image very important containerPort container port,this is necessary

func (*DaemonSet) SetEnvs

func (obj *DaemonSet) SetEnvs(envMap map[string]string) *DaemonSet

SetEnvs set Pod Environmental variable

func (*DaemonSet) SetHTTPLiveness

func (obj *DaemonSet) SetHTTPLiveness(port int, path string, initDelaySec, timeoutSec, periodSec int32, headers ...map[string]string) *DaemonSet

SetHTTPLiveness set container liveness of http style port: required path: http request URL,eg: /api/v1/posts/1 initDelaySec: how long time after the first start of the program the probe is executed for the first time.(sec) timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*DaemonSet) SetHTTPReadness

func (obj *DaemonSet) SetHTTPReadness(port int, path string, initDelaySec, timeoutSec, periodSec int32, headers ...map[string]string) *DaemonSet

SetHTTPReadness set container readness initDelaySec: how long time after the first start of the program the probe is executed for the first time.(sec) timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? on the other hand, only **first container** will be set livenessProbe

func (*DaemonSet) SetHistoryLimit

func (obj *DaemonSet) SetHistoryLimit(limit int32) *DaemonSet

SetHistoryLimit set DaemonSet history version numbers, limit default 10 the field is used to Rollback

func (*DaemonSet) SetImagePullSecrets

func (obj *DaemonSet) SetImagePullSecrets(secretName string) *DaemonSet

SetImagePullSecrets set pod pull secret

func (*DaemonSet) SetLabels

func (obj *DaemonSet) SetLabels(labels map[string]string) *DaemonSet

SetLabels set DaemonSet(ds) Labels,set Pod Labels.

func (*DaemonSet) SetMinReadySeconds

func (obj *DaemonSet) SetMinReadySeconds(sec int32) *DaemonSet

SetMinReadySeconds set DaemonSet minreadyseconds default 600

func (*DaemonSet) SetName

func (obj *DaemonSet) SetName(name string) *DaemonSet

SetName set DaemonSet(ds) name

func (*DaemonSet) SetNamespace

func (obj *DaemonSet) SetNamespace(namespace string) *DaemonSet

SetNamespace set DaemonSet(ds) namespace, default namespace value is 'default'

func (*DaemonSet) SetNamespaceAndName

func (obj *DaemonSet) SetNamespaceAndName(namespace, name string) *DaemonSet

SetNamespaceAndName set DaemonSet namespace and DaemonSet name and Pod Namespace

func (*DaemonSet) SetPVCMounts

func (obj *DaemonSet) SetPVCMounts(volumeName, mountPath string) *DaemonSet

SetPVCMounts mount PersistentVolumeClaim on container params: volumeName:the param is SetPVClaim() function volumeName,and when you call SetPVCMounts function you must call SetPVClaim function,and no order. on the other hand SetPVCMounts() function only mount first Container,and On the Container you can volumeMount many PersistentVolumeClaim. mountPath: runtime container dir eg:/var/lib/mysql

func (*DaemonSet) SetPVClaim

func (obj *DaemonSet) SetPVClaim(volumeName, claimName string) *DaemonSet

SetPVClaim set DaemonSet PersistentVolumeClaimVolumeSource params: volumeName: this is Custom field,you can define VolumeSource name,will be used of the container MountPath, claimName: this is PersistentVolumeClaim(PVC) name,the PVC and DaemonSet must on same namespace and exist.

func (*DaemonSet) SetPodLabels

func (obj *DaemonSet) SetPodLabels(labels map[string]string) *DaemonSet

SetPodLabels set Pod Label and set DaemonSet Selector

func (*DaemonSet) SetPodPriorityClass

func (obj *DaemonSet) SetPodPriorityClass(priorityClassName string) *DaemonSet

SetPodPriorityClass set DaemonSet Pod Priority priorityClassName is Kubernetes resource object PriorityClass name priorityClassName must already exists in kubernetes cluster

func (*DaemonSet) SetPodQos

func (obj *DaemonSet) SetPodQos(qosClass string, autoSet ...bool) *DaemonSet

SetPodQos set pod quality of service qosClass: is quality of service,the value only 'Guaranteed','Burstable' and 'BestEffort' autoSet: If your previous settings do not meet the requirements of PodQoS, we will automatically set

func (*DaemonSet) SetPostStartExec

func (obj *DaemonSet) SetPostStartExec(command []string) *DaemonSet

SetPostStartExec set PostStart shell command style PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*DaemonSet) SetPostStartHTTP

func (obj *DaemonSet) SetPostStartHTTP(scheme URIScheme, host string, port int, path string, headers ...map[string]string) *DaemonSet

SetPostStartHTTP set PostStart http style PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*DaemonSet) SetPreStopExec

func (obj *DaemonSet) SetPreStopExec(command []string) *DaemonSet

SetPreStopExec set StatefulSet PreStop command PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*DaemonSet) SetPreStopHTTP

func (obj *DaemonSet) SetPreStopHTTP(scheme URIScheme, host string, port int, path string, headers ...map[string]string) *DaemonSet

SetPreStopHTTP set preStop http style PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*DaemonSet) SetSelector

func (obj *DaemonSet) SetSelector(selector map[string]string) *DaemonSet

SetSelector set DaemonSet(ds) Selector and Set Pod Label The Pod that matches the seletor will be selected, DaemonSet will controller the Pod.

func (*DaemonSet) SetTCPLiveness

func (obj *DaemonSet) SetTCPLiveness(host string, port int, initDelaySec, timeoutSec, periodSec int32) *DaemonSet

SetTCPLiveness set container liveness of tcp style host: default is "" port: required timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*DaemonSet) SetTCPReadness

func (obj *DaemonSet) SetTCPReadness(host string, port int, initDelaySec, timeoutSec, periodSec int32) *DaemonSet

SetTCPReadness set container readness of tcp style host: default is "" port: required timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*DaemonSet) YAMLNew

func (obj *DaemonSet) YAMLNew(yamlbyts []byte) *DaemonSet

YAMLNew use yaml data create DaemonSet

type Deployment

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

Deployment include Kubernetes resource object Deployment and error

func NewDeployment

func NewDeployment() *Deployment

NewDeployment create Deployment and Chain function call begin with this function.

func (*Deployment) Apply

func (obj *Deployment) Apply() (*v1.Deployment, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*Deployment) DelNodeAffinity

func (obj *Deployment) DelNodeAffinity(keys []string) *Deployment

DelNodeAffinity delete node affinitys keys is delete key list

func (*Deployment) Finish

func (obj *Deployment) Finish() (dp *v1.Deployment, err error)

Finish Chain function call end with this function return Kubernetes resource object Deployment and error. In the function, it will check necessary parametersainput the default field

func (*Deployment) GetPodLabel

func (obj *Deployment) GetPodLabel() map[string]string

GetPodLabel get Pod labels

func (*Deployment) ImagePullPolicy

func (obj *Deployment) ImagePullPolicy(pullPolicy PullPolicy) *Deployment

ImagePullPolicy Deployment pull image policy:Always,Never,IfNotPresent

func (*Deployment) JSONNew

func (obj *Deployment) JSONNew(jsonbyts []byte) *Deployment

JSONNew use json data create Deployment

func (*Deployment) Release

func (obj *Deployment) Release() (*v1.Deployment, error)

Release release Deployment on Kubernetes

func (*Deployment) Replace

func (obj *Deployment) Replace(dp *v1.Deployment) *Deployment

Replace replace Deployment by Kubernetes resource object

func (*Deployment) SetAnnotations

func (obj *Deployment) SetAnnotations(annotations map[string]string) *Deployment

SetAnnotations set Deployment annotations

func (*Deployment) SetCMDLiveness

func (obj *Deployment) SetCMDLiveness(cmd []string, initDelaySec, timeoutSec, periodSec int32) *Deployment

SetCMDLiveness set container liveness of cmd style cmd: execute liveness probe as commond line timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*Deployment) SetCMDReadness

func (obj *Deployment) SetCMDReadness(cmd []string, initDelaySec, timeoutSec, periodSec int32) *Deployment

SetCMDReadness set container readness of cmd style cmd: execute readness probe as commond line timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*Deployment) SetContainer

func (obj *Deployment) SetContainer(name, image string, containerPort int32) *Deployment

SetContainer set Deployment container name:name is container name ,default "" image:image is image name ,must input image containerPort: image expose containerPort,must input containerPort

func (*Deployment) SetContainerOne

func (obj *Deployment) SetContainerOne(container corev1.Container) *Deployment

SetContainerOne set one container

func (*Deployment) SetDeployMaxTime

func (obj *Deployment) SetDeployMaxTime(sec int32) *Deployment

SetDeployMaxTime set Deployment deploy max time,default 600s. If real deploy time more than this value,Deployment controller return err:ProgressDeadlineExceeded and Pod will Redeploy.

func (*Deployment) SetEnvs

func (obj *Deployment) SetEnvs(envMap map[string]string) *Deployment

SetEnvs set Pod Environmental variable

func (*Deployment) SetHTTPLiveness

func (obj *Deployment) SetHTTPLiveness(port int, path string, initDelaySec, timeoutSec, periodSec int32, headers ...map[string]string) *Deployment

SetHTTPLiveness set container liveness of http style port: required path: http request URL,eg: /api/v1/posts/1 initDelaySec: how long time after the first start of the program the probe is executed for the first time.(sec) timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*Deployment) SetHTTPReadness

func (obj *Deployment) SetHTTPReadness(port int, path string, initDelaySec, timeoutSec, periodSec int32, headers ...map[string]string) *Deployment

SetHTTPReadness set container readness initDelaySec: how long time after the first start of the program the probe is executed for the first time.(sec) timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? on the other hand, only **first container** will be set livenessProbe

func (*Deployment) SetHistoryLimit

func (obj *Deployment) SetHistoryLimit(limit int32) *Deployment

SetHistoryLimit set Deployment history version numbers, limit default 10 the field is used to Rollback

func (*Deployment) SetImagePullSecrets

func (obj *Deployment) SetImagePullSecrets(secretName string) *Deployment

SetImagePullSecrets set pod pull secret

func (*Deployment) SetLabels

func (obj *Deployment) SetLabels(labels map[string]string) *Deployment

SetLabels set Deployment labels

func (*Deployment) SetMatchExpressions

func (obj *Deployment) SetMatchExpressions(ents []LabelSelectorRequirement) *Deployment

SetMatchExpressions set Deployment match expressions the field is used to set complicated Label.

func (*Deployment) SetMinReadySeconds

func (obj *Deployment) SetMinReadySeconds(sec int32) *Deployment

SetMinReadySeconds set Deployment minreadyseconds default 600

func (*Deployment) SetName

func (obj *Deployment) SetName(name string) *Deployment

SetName set Deployment name

func (*Deployment) SetNamespace

func (obj *Deployment) SetNamespace(namespace string) *Deployment

SetNamespace set Deployment namespace and set Pod namespace.

func (*Deployment) SetNamespaceAndName

func (obj *Deployment) SetNamespaceAndName(namespace, name string) *Deployment

SetNamespaceAndName set Deployment namespace,set Pod namespace,set Deployment name.

func (*Deployment) SetPVCMounts

func (obj *Deployment) SetPVCMounts(volumeName, mountPath string) *Deployment

SetPVCMounts mount PersistentVolumeClaim on container params: volumeName:the param is SetPVClaim() function volumeName,and when you call SetPVCMounts function you must call SetPVClaim function,and no order. on the other hand SetPVCMounts() function only mount first Container,and On the Container you can volumeMount many PersistentVolumeClaim. mountPath: runtime container dir eg:/var/lib/mysql

func (*Deployment) SetPVClaim

func (obj *Deployment) SetPVClaim(volumeName, claimName string) *Deployment

SetPVClaim set Deployment PersistentVolumeClaimVolumeSource params: volumeName: this is Custom field,you can define VolumeSource name,will be used of the container MountPath, claimName: this is PersistentVolumeClaim(PVC) name,the PVC and Deployment must on same namespace and exist.

func (*Deployment) SetPodLabels

func (obj *Deployment) SetPodLabels(labels map[string]string) *Deployment

SetPodLabels set Pod labels when call SetLabels(),you can not use this function.

func (*Deployment) SetPodPriorityClass

func (obj *Deployment) SetPodPriorityClass(priorityClassName string) *Deployment

SetPodPriorityClass set Deployment Pod Priority priorityClassName is Kubernetes resource object PriorityClass name priorityClassName must already exists in kubernetes cluster

func (*Deployment) SetPodQos

func (obj *Deployment) SetPodQos(qosClass string, autoSet ...bool) *Deployment

SetPodQos set pod quality of service qosClass: is quality of service,the value only 'Guaranteed','Burstable' and 'BestEffort' autoSet: If your previous settings do not meet the requirements of PodQoS, we will automatically set

func (*Deployment) SetPostStartExec

func (obj *Deployment) SetPostStartExec(command []string) *Deployment

SetPostStartExec set PostStart shell command style PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*Deployment) SetPostStartHTTP

func (obj *Deployment) SetPostStartHTTP(scheme URIScheme, host string, port int, path string, headers ...map[string]string) *Deployment

SetPostStartHTTP set PostStart http style PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*Deployment) SetPreStopExec

func (obj *Deployment) SetPreStopExec(command []string) *Deployment

SetPreStopExec set StatefulSet PreStop command PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*Deployment) SetPreStopHTTP

func (obj *Deployment) SetPreStopHTTP(scheme URIScheme, host string, port int, path string, headers ...map[string]string) *Deployment

SetPreStopHTTP set preStop http style PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*Deployment) SetPreferredNodeAffinity

func (obj *Deployment) SetPreferredNodeAffinity(weight int32, key string, value []string, operator NodeSelectorOperator) *Deployment

SetPreferredNodeAffinity set node affinity for PreferredDuringSchedulingIgnoredDuringExecution style

func (*Deployment) SetReplicas

func (obj *Deployment) SetReplicas(replicas int32) *Deployment

SetReplicas set Deployment replicas default 1

func (*Deployment) SetRequiredAndNodeAffinity

func (obj *Deployment) SetRequiredAndNodeAffinity(key string, value []string, operator NodeSelectorOperator) *Deployment

SetRequiredAndNodeAffinity set node affinity for RequiredDuringSchedulingIgnoredDuringExecution style A list of keys, many key do AND operation.

func (*Deployment) SetRequiredORNodeAffinity

func (obj *Deployment) SetRequiredORNodeAffinity(key string, value []string, operator NodeSelectorOperator) *Deployment

SetRequiredORNodeAffinity set node affinity for RequiredDuringSchedulingIgnoredDuringExecution style A list of keys, many key do OR operation.

func (*Deployment) SetResourceLimit

func (obj *Deployment) SetResourceLimit(limits map[ResourceName]string) *Deployment

SetResourceLimit set container of deployment resource limit,eg:CPU and MEMORY

func (*Deployment) SetResourceRequst

func (obj *Deployment) SetResourceRequst(requests map[ResourceName]string) *Deployment

SetResourceRequst set container of deployment resource request,only CPU and MEMORY

func (*Deployment) SetSelector

func (obj *Deployment) SetSelector(labels map[string]string) *Deployment

SetSelector set Deployment selector set: 1. Deployment.Spec.Selector 2. Deployment.Spec.Template.Label(the Field is Pod Labels.) and you can not be SetLabels

func (*Deployment) SetTCPLiveness

func (obj *Deployment) SetTCPLiveness(host string, port int, initDelaySec, timeoutSec, periodSec int32) *Deployment

SetTCPLiveness set container liveness of tcp style host: default is "" port: required timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*Deployment) SetTCPReadness

func (obj *Deployment) SetTCPReadness(host string, port int, initDelaySec, timeoutSec, periodSec int32) *Deployment

SetTCPReadness set container readness of tcp style host: default is "" port: required timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*Deployment) SetToleration

func (obj *Deployment) SetToleration(key, value string, operator TolerationOperator, effect TaintEffect, delayTimeSec ...int64) *Deployment

SetToleration set Taints Tolerations delayTimeSec TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. +optional operator default is Equal

func (*Deployment) YAMLNew

func (obj *Deployment) YAMLNew(yamlbyts []byte) *Deployment

YAMLNew use yaml data create Deployment

type LabelSelector

type LabelSelector struct {
	// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
	// map is equivalent to an element of matchExpressions, whose key field is "key", the
	// operator is "In", and the values array contains only "value". The requirements are ANDed.
	// +optional
	MatchLabels map[string]string `json:"matchLabels,omitempty" protobuf:"bytes,1,rep,name=matchLabels"`
	// matchExpressions is a list of label selector requirements. The requirements are ANDed.
	// +optional
	MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty" protobuf:"bytes,2,rep,name=matchExpressions"`
}

LabelSelector : A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.

type LabelSelectorOperator

type LabelSelectorOperator string

LabelSelectorOperator :A label selector operator is the set of operators that can be used in a selector requirement.

const (
	LabelSelectorOpIn           LabelSelectorOperator = "In"
	LabelSelectorOpNotIn        LabelSelectorOperator = "NotIn"
	LabelSelectorOpExists       LabelSelectorOperator = "Exists"
	LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
)

LabelSelectorOperator params

type LabelSelectorRequirement

type LabelSelectorRequirement struct {
	// key is the label key that the selector applies to.
	// +patchMergeKey=key
	// +patchStrategy=merge
	Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key" protobuf:"bytes,1,opt,name=key"`
	// operator represents a key's relationship to a set of values.
	// Valid operators are In, NotIn, Exists and DoesNotExist.
	Operator LabelSelectorOperator `json:"operator" protobuf:"bytes,2,opt,name=operator,casttype=LabelSelectorOperator"`
	// values is an array of string values. If the operator is In or NotIn,
	// the values array must be non-empty. If the operator is Exists or DoesNotExist,
	// the values array must be empty. This array is replaced during a strategic
	// merge patch.
	// +optional
	Values []string `json:"values,omitempty" protobuf:"bytes,3,rep,name=values"`
}

LabelSelectorRequirement : A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.

type NFSVolumeSource

type NFSVolumeSource struct {
	// Server is the hostname or IP address of the NFS server.
	// More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
	Server string `json:"server" protobuf:"bytes,1,opt,name=server"`

	// Path that is exported by the NFS server.
	// More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
	Path string `json:"path" protobuf:"bytes,2,opt,name=path"`

	// ReadOnly here will force
	// the NFS export to be mounted with read-only permissions.
	// Defaults to false.
	// More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
	// +optional
	ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,3,opt,name=readOnly"`
}

NFSVolumeSource : Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do not support ownership management or SELinux relabeling.

type Namespace

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

Namespace include Kubernets resource object Namespace and err

func NewNs

func NewNs() *Namespace

NewNs create Namespace and Chain function call begin with this function.

func (*Namespace) Apply

func (obj *Namespace) Apply() (*v1.Namespace, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*Namespace) Finish

func (obj *Namespace) Finish() (*v1.Namespace, error)

Finish Chain function call end with this function return Kubernetes resource object Namespace and error. In the function, it will check necessary parameters�input the default field

func (*Namespace) Release

func (obj *Namespace) Release() (*v1.Namespace, error)

Release release Namespace on Kubernetes

func (*Namespace) SetName

func (obj *Namespace) SetName(name string) *Namespace

SetName set namespace name

type Node

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

Node include Kubernetes resource object node and error

func JSONNewNode

func JSONNewNode(jsonbyts []byte) *Node

JSONNewNode use json data create Node

func ReadNewNode

func ReadNewNode(coreNode *v1.Node) *Node

ReadNewNode read new node

func YAMLNewNode

func YAMLNewNode(yamlbyts []byte) *Node

YAMLNewNode use yaml data create Node

func (*Node) DelNodeLabels

func (obj *Node) DelNodeLabels(labels map[string]string) *Node

DelNodeLabels del node labels Skip if there is no such key

func (*Node) Finish

func (obj *Node) Finish() (node *v1.Node, err error)

Finish Chain function call end with this function return Kubernetes resource object Node and error. In the function, it will check necessary parametersainput the default field

func (*Node) SetAnnotations

func (obj *Node) SetAnnotations(annotations map[string]string) *Node

SetAnnotations set Node annotations

func (*Node) SetLabels

func (obj *Node) SetLabels(labels map[string]string) *Node

SetLabels set node Label If the key already exists on node.Labels, the value will be replaced with the new one.

func (*Node) SetTaints

func (obj *Node) SetTaints(key, value string, effect TaintEffect) *Node

SetTaints set Taint

type NodeSelectorOperator

type NodeSelectorOperator string

NodeSelectorOperator A node selector operator is the set of operators that can be used in a node selector requirement.

const (
	NodeSelectorOpIn           NodeSelectorOperator = "In"
	NodeSelectorOpNotIn        NodeSelectorOperator = "NotIn"
	NodeSelectorOpExists       NodeSelectorOperator = "Exists"
	NodeSelectorOpDoesNotExist NodeSelectorOperator = "DoesNotExist"
	NodeSelectorOpGt           NodeSelectorOperator = "Gt"
	NodeSelectorOpLt           NodeSelectorOperator = "Lt"
)

NodeSelector seletctors

func (NodeSelectorOperator) ToK8s

ToK8s local NodeSelectorOperator to kubernetes NodeSelectorOperator

type PersistentVolume

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

PersistentVolume include Kubernetes resource object PersistentVolume(pv) and error.

func NewPV

func NewPV() *PersistentVolume

NewPV create PersistentVolume and chain function call begin with this function.

func (*PersistentVolume) Apply

func (obj *PersistentVolume) Apply() (*v1.PersistentVolume, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*PersistentVolume) Finish

func (obj *PersistentVolume) Finish() (*v1.PersistentVolume, error)

Finish chain function call end with this function return Kubernetes resource object PersistentVolume(pv) and error. In the function, it will check necessary parameters、input the default field。

func (*PersistentVolume) GetLabels

func (obj *PersistentVolume) GetLabels() map[string]string

GetLabels get PersistentVolume(pv) labels

func (*PersistentVolume) GetName

func (obj *PersistentVolume) GetName() string

GetName get PersistentVolume(pv) name

func (*PersistentVolume) JSONNew

func (obj *PersistentVolume) JSONNew(jsonbyte []byte) *PersistentVolume

JSONNew use json data create PersistentVolume(pv)

func (*PersistentVolume) Release

func (obj *PersistentVolume) Release() (*v1.PersistentVolume, error)

Release release PersistentVolume on Kubernetes

func (*PersistentVolume) Replace

Replace replace PersistentVolume by Kubernetes resource object

func (*PersistentVolume) SetAccessMode

SetAccessMode set PersistentVolume(pv) access mode, only one

func (*PersistentVolume) SetAccessModes

func (obj *PersistentVolume) SetAccessModes(modes []PersistentVolumeAccessMode) *PersistentVolume

SetAccessModes set PersistentVolume(pv) access mode, many modes

func (*PersistentVolume) SetAnnotations

func (obj *PersistentVolume) SetAnnotations(annotations map[string]string) *PersistentVolume

SetAnnotations set PersistentVolume(pv) annotations

func (*PersistentVolume) SetCapacity

func (obj *PersistentVolume) SetCapacity(capMaps map[ResourceName]string) *PersistentVolume

SetCapacity set PersistentVolume(pv) capacity

func (*PersistentVolume) SetCephFS

SetCephFS set PersistentVolume(pv) volume source is ceph

func (*PersistentVolume) SetLabels

func (obj *PersistentVolume) SetLabels(labels map[string]string) *PersistentVolume

SetLabels set PersistentVolume(pv) label

func (*PersistentVolume) SetNFS

SetNFS set PersistentVolume(pv) volume source is nfs

func (*PersistentVolume) SetName

func (obj *PersistentVolume) SetName(name string) *PersistentVolume

SetName set PersistentVolume(pv) name

func (*PersistentVolume) SetRBD

SetRBD set PersistentVolume(pv) volume source is RBD

func (*PersistentVolume) SetReclaimPolicy

func (obj *PersistentVolume) SetReclaimPolicy(reclaimPolicy PersistentVolumeReclaimPolicy) *PersistentVolume

SetReclaimPolicy set setReclaim policy

func (*PersistentVolume) YAMLNew

func (obj *PersistentVolume) YAMLNew(yamlbyts []byte) *PersistentVolume

YAMLNew use yaml data create PersistentVolume(pv)

type PersistentVolumeAccessMode

type PersistentVolumeAccessMode string

PersistentVolumeAccessMode volume access mode read,write

const (
	// can be mounted read/write mode to exactly 1 host
	ReadWriteOnce PersistentVolumeAccessMode = "ReadWriteOnce"
	// can be mounted in read-only mode to many hosts
	ReadOnlyMany PersistentVolumeAccessMode = "ReadOnlyMany"
	// can be mounted in read/write mode to many hosts
	ReadWriteMany PersistentVolumeAccessMode = "ReadWriteMany"
	RWO           PersistentVolumeAccessMode = "RWO"
	ROX           PersistentVolumeAccessMode = "ROX"
	RWX           PersistentVolumeAccessMode = "RWX"
)

VolumeAccessMode params

func (PersistentVolumeAccessMode) ToK8s

ToK8s translate into k8s accessMode

type PersistentVolumeClaim

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

PersistentVolumeClaim include kubernetes resource object PersistentVolumeClaim(pvc) and error.

func NewPVC

func NewPVC() *PersistentVolumeClaim

NewPVC create PersistentVolumeClaim(pvc) and chain function call begin with this function.

func (*PersistentVolumeClaim) Apply

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*PersistentVolumeClaim) Finish

Finish Chain function call end with this function return Kubernetes resource object PersistentVolumeClaim(pvc) and error. In the function, it will check necessary parameters?input the default field?

func (*PersistentVolumeClaim) GetLabels

func (obj *PersistentVolumeClaim) GetLabels() map[string]string

GetLabels get PersistentVolumeClaim(pvc) labels

func (*PersistentVolumeClaim) GetName

func (obj *PersistentVolumeClaim) GetName() string

GetName get PersistentVolumeClaim(pvc) name

func (*PersistentVolumeClaim) GetNamespace

func (obj *PersistentVolumeClaim) GetNamespace() string

GetNamespace get PersistentVolumeClaim(pvc) namespace

func (*PersistentVolumeClaim) GetSelector

func (obj *PersistentVolumeClaim) GetSelector() map[string]string

GetSelector get PersistentVolumeClaim(pvc) selector

func (*PersistentVolumeClaim) JSONNew

func (obj *PersistentVolumeClaim) JSONNew(jsonbyts []byte) *PersistentVolumeClaim

JSONNew use json data create PersistentVolumeClaim(pvc)

func (*PersistentVolumeClaim) Release

Release release PersistentVolumeClaim on Kubernetes

func (*PersistentVolumeClaim) Replace

Replace replace PersistentVolumeClaim by Kubernetes resource object

func (*PersistentVolumeClaim) SetAccessMode

SetAccessMode set PersistentVolumeClaim(pvc) access mode, only one

func (*PersistentVolumeClaim) SetAccessModes

SetAccessModes set PersistentVolumeClaim(pvc) accessModes, many modes

func (*PersistentVolumeClaim) SetAnnotations

func (obj *PersistentVolumeClaim) SetAnnotations(annotations map[string]string) *PersistentVolumeClaim

SetAnnotations set PersistentVolumeClaim(pvc) annotations

func (*PersistentVolumeClaim) SetLabels

func (obj *PersistentVolumeClaim) SetLabels(labels map[string]string) *PersistentVolumeClaim

SetLabels set PersistentVolumeClaim(pvc) labels

func (*PersistentVolumeClaim) SetMatchExpressions

func (obj *PersistentVolumeClaim) SetMatchExpressions(ents []LabelSelectorRequirement) *PersistentVolumeClaim

SetMatchExpressions set Deployment match expressions the field is used to set complicated Label.

func (*PersistentVolumeClaim) SetName

SetName set PersistentVolumeClaim(pvc) name

func (*PersistentVolumeClaim) SetNamespace

func (obj *PersistentVolumeClaim) SetNamespace(namespace string) *PersistentVolumeClaim

SetNamespace set PersistentVolumeClaim(pvc) namespace,default namespace is 'default'

func (*PersistentVolumeClaim) SetNamespaceAndName

func (obj *PersistentVolumeClaim) SetNamespaceAndName(namespace, name string) *PersistentVolumeClaim

SetNamespaceAndName set Deployment namespace,set Pod namespace,set Deployment name.

func (*PersistentVolumeClaim) SetResourceLimits

func (obj *PersistentVolumeClaim) SetResourceLimits(limits map[ResourceName]string) *PersistentVolumeClaim

SetResourceLimits set PersistentVolumeClaim(pvc) resource limits

func (*PersistentVolumeClaim) SetResourceRequests

func (obj *PersistentVolumeClaim) SetResourceRequests(requests map[ResourceName]string) *PersistentVolumeClaim

SetResourceRequests set PersistentVolumeClaim(pvc) reource requests

func (*PersistentVolumeClaim) SetSelector

func (obj *PersistentVolumeClaim) SetSelector(labels map[string]string) *PersistentVolumeClaim

SetSelector set PersistentVolumeClaim(pvc) selector

func (*PersistentVolumeClaim) SetStorageClassName

func (obj *PersistentVolumeClaim) SetStorageClassName(classname string) *PersistentVolumeClaim

SetStorageClassName set PersistentVolumeClaim(pvc) storageclasss name

func (*PersistentVolumeClaim) SetVolumeMode

func (obj *PersistentVolumeClaim) SetVolumeMode(volumeMode PersistentVolumeMode) *PersistentVolumeClaim

SetVolumeMode PersistentVolumeClaim(pvc) vloume mode,have Block and Filesystem mode

func (*PersistentVolumeClaim) YAMLNew

func (obj *PersistentVolumeClaim) YAMLNew(yamlbyts []byte) *PersistentVolumeClaim

YAMLNew use yaml data create PersistentVolumeClaim(pvc)

type PersistentVolumeMode

type PersistentVolumeMode string

PersistentVolumeMode describes how a volume is intended to be consumed, either Block or Filesystem.

const (
	// PersistentVolumeBlock means the volume will not be formatted with a filesystem and will remain a raw block device.
	PersistentVolumeBlock PersistentVolumeMode = "Block"
	// PersistentVolumeFilesystem means the volume will be or is formatted with a filesystem.
	PersistentVolumeFilesystem PersistentVolumeMode = "Filesystem"
)

func (PersistentVolumeMode) ToK8s

ToK8s PersistentVolumeMode translate into k8s PersistentVolumeMode

type PersistentVolumeReclaimPolicy

type PersistentVolumeReclaimPolicy string

PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes.

const (
	// PersistentVolumeReclaimRecycle means the volume will be recycled back into the pool of unbound persistent volumes on release from its claim.
	// The volume plugin must support Recycling.
	PersistentVolumeReclaimRecycle PersistentVolumeReclaimPolicy = "Recycle"
	// PersistentVolumeReclaimDelete means the volume will be deleted from Kubernetes on release from its claim.
	// The volume plugin must support Deletion.
	PersistentVolumeReclaimDelete PersistentVolumeReclaimPolicy = "Delete"
	// PersistentVolumeReclaimRetain means the volume will be left in its current phase (Released) for manual reclamation by the administrator.
	// The default policy is Retain.
	PersistentVolumeReclaimRetain PersistentVolumeReclaimPolicy = "Retain"
)

func (PersistentVolumeReclaimPolicy) ToK8s

ToK8s local PersistentVolumeReclaimPolicy to kubernetest PersistentVolumeReclaimPolicy

type Pod

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

Pod include Kubernetes resource bject Pod and error

func NewPod

func NewPod() *Pod

NewPod create Pod and hain function call begin with this function.

func (*Pod) Finish

func (obj *Pod) Finish() (pod *v1.Pod, err error)

Finish Chain function call end with this function return Kubernetes resource object Pod and error. In the function, it will check necessary parametersainput the default field

func (*Pod) JSONNew

func (obj *Pod) JSONNew(jsonbyts []byte) *Pod

JSONNew use json data create Pod

func (*Pod) SetContainer

func (obj *Pod) SetContainer(name, image string, containerPort int32) *Pod

SetContainer set pod container name:name is container name ,default "" image:image is image name ,must input image containerPort: image expose containerPort,must input containerPort

func (*Pod) SetLabels

func (obj *Pod) SetLabels(labels map[string]string) *Pod

SetLabels set pod labels

func (*Pod) SetName

func (obj *Pod) SetName(name string) *Pod

SetName set Pod name

func (*Pod) SetNamespace

func (obj *Pod) SetNamespace(namespace string) *Pod

SetNamespace set Pod namespace and set Pod namespace.

func (*Pod) SetNamespaceAndName

func (obj *Pod) SetNamespaceAndName(namespace, name string) *Pod

SetNamespaceAndName set Pod Namespace and Pod name

func (*Pod) YAMLNew

func (obj *Pod) YAMLNew(yamlbyts []byte) *Pod

YAMLNew use yaml data create Pod

type PodQOSClass

type PodQOSClass string

PodQOSClass defines the supported qos classes of Pods.

const (
	// PodQOSGuaranteed is the Guaranteed qos class.
	PodQOSGuaranteed PodQOSClass = "Guaranteed"
	// PodQOSBurstable is the Burstable qos class.
	PodQOSBurstable PodQOSClass = "Burstable"
	// PodQOSBestEffort is the BestEffort qos class.
	PodQOSBestEffort PodQOSClass = "BestEffort"
)

func (PodQOSClass) ToK8s

func (qos PodQOSClass) ToK8s() v1.PodQOSClass

ToK8s set pod qos

type Protocol

type Protocol string

Protocol defines network protocols supported for things like container ports.

const (
	// ProtocolTCP is the TCP protocol.
	ProtocolTCP Protocol = "TCP"
	// ProtocolUDP is the UDP protocol.
	ProtocolUDP Protocol = "UDP"
)

func (Protocol) ToK8s

func (pro Protocol) ToK8s() v1.Protocol

ToK8s translate into Kubernetes Protocol

type PullPolicy

type PullPolicy string

PullPolicy describes a policy for if/when to pull a container image

const (
	// PullAlways means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.
	PullAlways PullPolicy = "Always"
	// PullNever means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present
	PullNever PullPolicy = "Never"
	// PullIfNotPresent means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.
	PullIfNotPresent PullPolicy = "IfNotPresent"
	// ImagePullPolicyKey anotation
	ImagePullPolicyKey = "imagePullPolicy"
)

func (PullPolicy) ToK8s

func (pp PullPolicy) ToK8s() v1.PullPolicy

ToK8s image pull policy

type QOSList

type QOSList map[v1.ResourceName]v1.PodQOSClass

QOSList is a set of (resource name, QoS class) pairs.

type RBDPersistentVolumeSource

type RBDPersistentVolumeSource struct {
	// A collection of Ceph monitors.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	CephMonitors []string `json:"monitors" protobuf:"bytes,1,rep,name=monitors"`
	// The rados image name.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	RBDImage string `json:"image" protobuf:"bytes,2,opt,name=image"`
	// Filesystem type of the volume that you want to mount.
	// Tip: Ensure that the filesystem type is supported by the host operating system.
	// Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
	// More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd
	// TODO: how do we prevent errors in the filesystem from compromising the machine
	// +optional
	FSType string `json:"fsType,omitempty" protobuf:"bytes,3,opt,name=fsType"`
	// The rados pool name.
	// Default is rbd.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	// +optional
	RBDPool string `json:"pool,omitempty" protobuf:"bytes,4,opt,name=pool"`
	// The rados user name.
	// Default is admin.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	// +optional
	RadosUser string `json:"user,omitempty" protobuf:"bytes,5,opt,name=user"`
	// Keyring is the path to key ring for RBDUser.
	// Default is /etc/ceph/keyring.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	// +optional
	Keyring string `json:"keyring,omitempty" protobuf:"bytes,6,opt,name=keyring"`
	// SecretRef is name of the authentication secret for RBDUser. If provided
	// overrides keyring.
	// Default is nil.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	// +optional
	SecretRef *SecretReference `json:"secretRef,omitempty" protobuf:"bytes,7,opt,name=secretRef"`
	// ReadOnly here will force the ReadOnly setting in VolumeMounts.
	// Defaults to false.
	// More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it
	// +optional
	ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,8,opt,name=readOnly"`
}

RBDPersistentVolumeSource Represents a Rados Block Device mount that lasts the lifetime of a pod. RBD volumes support ownership management and SELinux relabeling.

type ResourceName

type ResourceName string

ResourceName is the name identifying various resources in a ResourceList.

const (
	// CPU, in cores. (500m = .5 cores)
	ResourceCPU ResourceName = "cpu"
	// Memory, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
	ResourceMemory ResourceName = "memory"
	// Volume size, in bytes (e,g. 5Gi = 5GiB = 5 * 1024 * 1024 * 1024)
	ResourceStorage ResourceName = "storage"
	// Local ephemeral storage, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
	// The resource name for ResourceEphemeralStorage is alpha and it can change across releases.
	ResourceEphemeralStorage ResourceName = "ephemeral-storage"
	// NVIDIA GPU, in devices. Alpha, might change: although fractional and allowing values >1, only one whole device per node is assigned.
	ResourceNvidiaGPU ResourceName = "alpha.kubernetes.io/nvidia-gpu"
)

Resource names must be not more than 63 characters, consisting of upper- or lower-case alphanumeric characters, with the -, _, and . characters allowed anywhere, except the first or last character. The default convention, matching that for annotations, is to use lower-case names, with dashes, rather than camel case, separating compound words. Fully-qualified resource typenames are constructed from a DNS-style subdomain, followed by a slash `/` and a name.

func (ResourceName) ToK8s

func (r ResourceName) ToK8s() v1.ResourceName

ToK8s translate into k8s ResourceName

type Secret

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

Secret include Kuebernetes resource object Secret and error.

func NewSecret

func NewSecret() *Secret

NewSecret create Secret and chain function call begin with this function.

func (*Secret) Apply

func (obj *Secret) Apply() (*v1.Secret, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*Secret) Finish

func (obj *Secret) Finish() (*v1.Secret, error)

Finish chain function call end with this function. return obj(Kubernetes resource object) and error In the function, it will check necessary parameters、input the default field。

func (*Secret) JSONNew

func (obj *Secret) JSONNew(jsonbyts []byte) *Secret

JSONNew use json data create Secret

func (*Secret) Release

func (obj *Secret) Release() (*v1.Secret, error)

Release release Secret on Kubernetes

func (*Secret) Replace

func (obj *Secret) Replace(sec *v1.Secret) *Secret

Replace replace Secret by Kubernetes resource object

func (*Secret) SetDataBytes

func (obj *Secret) SetDataBytes(bytes map[string][]byte) *Secret

SetDataBytes set Secret data for byte,and Don't need to encode base64,because K8S will automatically encrypt

func (*Secret) SetDataString

func (obj *Secret) SetDataString(datas map[string]string) *Secret

SetDataString set Secret data, and Don't need to encode base64,because K8S will automatically encrypt

func (*Secret) SetLabels

func (obj *Secret) SetLabels(labels map[string]string) *Secret

SetLabels set Secret labels

func (*Secret) SetName

func (obj *Secret) SetName(name string) *Secret

SetName set Secret name

func (*Secret) SetNamespace

func (obj *Secret) SetNamespace(namespace string) *Secret

SetNamespace set Secret namespace ,default namespace is 'default'

func (*Secret) SetNamespaceAndName

func (obj *Secret) SetNamespaceAndName(namespace, name string) *Secret

SetNamespaceAndName set Secret namespace and name

func (*Secret) SetType

func (obj *Secret) SetType(secType SecretType) *Secret

SetType set Secret type,have Opaque and kubernetes.io/service-account-token Opaque user-defined data kubernetes.io/service-account-token is used to kubernetes apiserver,because apiserver need to auth

func (*Secret) YAMLNew

func (obj *Secret) YAMLNew(yamlbyts []byte) *Secret

YAMLNew use yaml data create Secret

type SecretReference

type SecretReference struct {
	// Name is unique within a namespace to reference a secret resource.
	// +optional
	Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
	// Namespace defines the space within which the secret name must be unique.
	// +optional
	Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"`
}

SecretReference represents a Secret Reference. It has enough information to retrieve secret in any namespace

type SecretType

type SecretType string

SecretType 'Opaque' or 'kubernetes.io/service-account-token'

const (
	// SecretTypeOpaque is the default. Arbitrary user-defined data
	SecretTypeOpaque SecretType = "Opaque"

	// SecretTypeServiceAccountToken contains a token that identifies a service account to the API
	//
	// Required fields:
	// - Secret.Annotations["kubernetes.io/service-account.name"] - the name of the ServiceAccount the token identifies
	// - Secret.Annotations["kubernetes.io/service-account.uid"] - the UID of the ServiceAccount the token identifies
	// - Secret.Data["token"] - a token that identifies the service account to the API
	SecretTypeServiceAccountToken SecretType = "kubernetes.io/service-account-token"
)

func (SecretType) ToK8s

func (ty SecretType) ToK8s() v1.SecretType

ToK8s translate into Kubernets SecretType

type Service

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

Service include Kubernetes resource object Service and error

func NewSvc

func NewSvc() *Service

NewSvc create service(svc) and chain function call begin with this function.

func (*Service) Apply

func (obj *Service) Apply() (*v1.Service, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*Service) Finish

func (obj *Service) Finish() (svc *v1.Service, err error)

Finish Chain function call end with this function return real service(really service is kubernetes resource object Service and error In the function, it will check necessary parametersainput the default field

func (*Service) Headless

func (obj *Service) Headless() *Service

Headless service headless

func (*Service) JSONNew

func (obj *Service) JSONNew(jsonbyts []byte) *Service

JSONNew use json data create service(svc)

func (*Service) Release

func (obj *Service) Release() (*v1.Service, error)

Release release Service on Kubernetes

func (*Service) Replace

func (obj *Service) Replace(svc *v1.Service) *Service

Replace replace Service by Kubernetes resource object

func (*Service) SetAnnotations

func (obj *Service) SetAnnotations(annotations map[string]string) *Service

SetAnnotations set service(svc) annotations

func (*Service) SetLabels

func (obj *Service) SetLabels(labels map[string]string) *Service

SetLabels set service(svc) labels

func (*Service) SetName

func (obj *Service) SetName(name string) *Service

SetName set service(svc) name

func (*Service) SetNamespace

func (obj *Service) SetNamespace(namespace string) *Service

SetNamespace set service(svc) namespace

func (*Service) SetNamespaceAndName

func (obj *Service) SetNamespaceAndName(namespace, name string) *Service

SetNamespaceAndName set service(svc) namespace and name namespace default value is 'default'

func (*Service) SetPort

func (obj *Service) SetPort(sp ServicePort) *Service

SetPort set service(svc) Port. port params required input on ServicePort default TargetPort same as Port NodePort is random number when not input or NodePort <= 0 Protocol default value 'TCP'

func (*Service) SetPorts

func (obj *Service) SetPorts(ports []ServicePort) *Service

SetPorts set service(svc) ports

func (*Service) SetSelector

func (obj *Service) SetSelector(selector map[string]string) *Service

SetSelector set service(svc) seletor The Pod that matches the selector will be selected the function Required call when you create service(svc)

func (*Service) SetServiceType

func (obj *Service) SetServiceType(sty ServiceType) *Service

SetServiceType set service(svc) type,you can choose NodePort,ClusterIP many info please redirect to ServiceType

func (*Service) SetSessionAffinity

func (obj *Service) SetSessionAffinity(affinity ServiceAffinity) *Service

SetSessionAffinity set service(svc) session affinity

func (*Service) YAMLNew

func (obj *Service) YAMLNew(yamlbyts []byte) *Service

YAMLNew use yaml data create service(svc)

type ServiceAccount

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

ServiceAccount include kubernetes resource object ServiceAccount(sa) and error

func NewSa

func NewSa() *ServiceAccount

NewSa create ServiceAccount(sa) and chain function call begin with this function.

func (*ServiceAccount) Finish

func (obj *ServiceAccount) Finish() (*corev1.ServiceAccount, error)

Finish Chain function call end with this function return Kubernetes resource object ServiceAccount and error. In the function, it will check necessary parameters、input the default field。

func (*ServiceAccount) SetNamespceAndName

func (obj *ServiceAccount) SetNamespceAndName(namespace, name string) *ServiceAccount

SetNamespceAndName set namespace and name, name is not allowed to be empty, name default is ""

type ServiceAffinity

type ServiceAffinity string

ServiceAffinity Type set affinity

const (
	// ServiceAffinityClientIP is the Client IP based.
	ServiceAffinityClientIP ServiceAffinity = "ClientIP"

	// ServiceAffinityNone - no session affinity.
	ServiceAffinityNone ServiceAffinity = "None"
)

affinity params

func (ServiceAffinity) ToK8s

func (sa ServiceAffinity) ToK8s() v1.ServiceAffinity

ToK8s translate into k8s aserviceAffinity

type ServicePort

type ServicePort struct {
	Name       string   `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
	Protocol   Protocol `json:"protocol,omitempty" protobuf:"bytes,2,opt,name=protocol,casttype=Protocol"`
	Port       int32    `json:"port" protobuf:"varint,3,opt,name=port"`
	TargetPort int      `json:"targetPort,omitempty" protobuf:"bytes,4,opt,name=targetPort"`
	NodePort   int32    `json:"nodePort,omitempty" protobuf:"varint,5,opt,name=nodePort"`
}

ServicePort service ports

type ServiceType

type ServiceType string

ServiceType service type

const (
	// ServiceTypeClusterIP means a service will only be accessible inside the
	// cluster, via the cluster IP.
	ServiceTypeClusterIP ServiceType = "ClusterIP"
	// ServiceTypeNodePort means a service will be exposed on one port of
	// every node, in addition to 'ClusterIP' type.
	ServiceTypeNodePort ServiceType = "NodePort"
	// ServiceTypeLoadBalancer means a service will be exposed via an
	// external load balancer (if the cloud provider supports it), in addition
	// to 'NodePort' type.
	ServiceTypeLoadBalancer ServiceType = "LoadBalancer"
	// ServiceTypeExternalName means a service consists of only a reference to
	// an external name that kubedns or equivalent will return as a CNAME
	// record, with no exposing or proxying of any pods involved.
	ServiceTypeExternalName ServiceType = "ExternalName"
)

ServiceType

func (ServiceType) ToK8s

func (sty ServiceType) ToK8s() v1.ServiceType

ToK8s translate into Kubernetes ServiceType

type StatefulSet

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

StatefulSet include kubernetes resource object StatefulSet(sts) and error

func NewSts

func NewSts() *StatefulSet

NewSts create StatefulSet(sts) and chain function call begin with this function.

func (*StatefulSet) Apply

func (obj *StatefulSet) Apply() (*v1.StatefulSet, error)

Apply it will be updated when this resource object exists in K8s, it will be created when it does not exist.

func (*StatefulSet) Finish

func (obj *StatefulSet) Finish() (*v1.StatefulSet, error)

Finish Chain function call end with this function return Kubernetes resource object StatefulSet and error. In the function, it will check necessary parameters、input the default field。

func (*StatefulSet) GetPodLabel

func (obj *StatefulSet) GetPodLabel() map[string]string

GetPodLabel get Pod labels

func (*StatefulSet) ImagePullPolicy

func (obj *StatefulSet) ImagePullPolicy(pullPolicy PullPolicy) *StatefulSet

ImagePullPolicy StatefulSet pull image policy:Always,Never,IfNotPresent

func (*StatefulSet) JSONNew

func (obj *StatefulSet) JSONNew(jsonbyts []byte) *StatefulSet

JSONNew use json data create StatelfulSet

func (*StatefulSet) Release

func (obj *StatefulSet) Release() (*v1.StatefulSet, error)

Release release StatefulSet on Kubernetes

func (*StatefulSet) Replace

func (obj *StatefulSet) Replace(sts *v1.StatefulSet) *StatefulSet

Replace replace StatefulSet by Kubernetes resource object

func (*StatefulSet) SetAnnotations

func (obj *StatefulSet) SetAnnotations(annotations map[string]string) *StatefulSet

SetAnnotations set StatefulSet annotations

func (*StatefulSet) SetCMDLiveness

func (obj *StatefulSet) SetCMDLiveness(cmd []string, initDelaySec, timeoutSec, periodSec int32) *StatefulSet

SetCMDLiveness set container liveness of cmd style cmd: execute liveness probe as commond line timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*StatefulSet) SetCMDReadness

func (obj *StatefulSet) SetCMDReadness(cmd []string, initDelaySec, timeoutSec, periodSec int32) *StatefulSet

SetCMDReadness set container readness of cmd style cmd: execute readness probe as commond line timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*StatefulSet) SetContainer

func (obj *StatefulSet) SetContainer(name, image string, containerPort int32) *StatefulSet

SetContainer set StatefulSet(sts) container name:name is container name ,default "" image:image is image name ,must input image containerPort: image expose containerPort,must input containerPort

func (*StatefulSet) SetEnvs

func (obj *StatefulSet) SetEnvs(envMap map[string]string) *StatefulSet

SetEnvs set Pod Environmental variable

func (*StatefulSet) SetHTTPLiveness

func (obj *StatefulSet) SetHTTPLiveness(port int, path string, initDelaySec, timeoutSec, periodSec int32, headers ...map[string]string) *StatefulSet

SetHTTPLiveness set container liveness of http style port: required path: http request URL,eg: /api/v1/posts/1 initDelaySec: how long time after the first start of the program the probe is executed for the first time.(sec) timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*StatefulSet) SetHTTPReadness

func (obj *StatefulSet) SetHTTPReadness(port int, path string, initDelaySec, timeoutSec, periodSec int32, headers ...map[string]string) *StatefulSet

SetHTTPReadness set container readness initDelaySec: how long time after the first start of the program the probe is executed for the first time.(sec) timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? on the other hand, only **first container** will be set livenessProbe

func (*StatefulSet) SetImagePullSecrets

func (obj *StatefulSet) SetImagePullSecrets(secretName string) *StatefulSet

SetImagePullSecrets set pod pull secret

func (*StatefulSet) SetLabels

func (obj *StatefulSet) SetLabels(labels map[string]string) *StatefulSet

SetLabels set StatefulSet(sts) Labels

func (*StatefulSet) SetName

func (obj *StatefulSet) SetName(name string) *StatefulSet

SetName set StatefulSet(sts) name

func (*StatefulSet) SetNamespace

func (obj *StatefulSet) SetNamespace(namespace string) *StatefulSet

SetNamespace set StatefulSet(sts) namespace ,default namespace is 'default'

func (*StatefulSet) SetNamespaceAndName

func (obj *StatefulSet) SetNamespaceAndName(namespace, name string) *StatefulSet

SetNamespaceAndName set StatefulSet namespace,set Pod namespace,set Deployment name.

func (*StatefulSet) SetPVCMounts

func (obj *StatefulSet) SetPVCMounts(volumeName, mountPath string) *StatefulSet

SetPVCMounts mount PersistentVolumeClaim on container params: volumeName:the param is SetPVClaim() function volumeName,and when you call SetPVCMounts function you must call SetPVClaim function,and no order. on the other hand SetPVCMounts() function only mount first Container,and On the Container you can volumeMount many PersistentVolumeClaim. mountPath: runtime container dir eg:/var/lib/mysql

func (*StatefulSet) SetPVCTemp

func (obj *StatefulSet) SetPVCTemp(pvcName, mountPath string, mode PersistentVolumeAccessMode, requests map[ResourceName]string) *StatefulSet

SetPVCTemp set StatefulSet PersistentVolumeClaimTemplate can't call SetPVCMounts() function when you call the function, because SetPVCMounts() function has been called automatically, Don't worry

func (*StatefulSet) SetPVClaim

func (obj *StatefulSet) SetPVClaim(volumeName, claimName string) *StatefulSet

SetPVClaim set StatefulSet PersistentVolumeClaimVolumeSource params: volumeName: this is Custom field,you can define VolumeSource name,will be used of the container MountPath, claimName: this is PersistentVolumeClaim(PVC) name,the PVC and StatefulSet must on same namespace and exist.

func (*StatefulSet) SetPodLabels

func (obj *StatefulSet) SetPodLabels(labels map[string]string) *StatefulSet

SetPodLabels set Pod labels and set StatefulSet(sts) selector

func (*StatefulSet) SetPodPriorityClass

func (obj *StatefulSet) SetPodPriorityClass(priorityClassName string) *StatefulSet

SetPodPriorityClass set StatefulSet Pod Priority priorityClassName is Kubernetes resource object PriorityClass name priorityClassName must already exists in kubernetes cluster

func (*StatefulSet) SetPodQos

func (obj *StatefulSet) SetPodQos(qosClass string, autoSet ...bool) *StatefulSet

SetPodQos set pod quality of service qosClass: is quality of service,the value only 'Guaranteed','Burstable' and 'BestEffort' autoSet: If your previous settings do not meet the requirements of PodQoS, we will automatically set

func (*StatefulSet) SetPostStartExec

func (obj *StatefulSet) SetPostStartExec(command []string) *StatefulSet

SetPostStartExec set PostStart shell command style PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*StatefulSet) SetPostStartHTTP

func (obj *StatefulSet) SetPostStartHTTP(scheme URIScheme, host string, port int, path string, headers ...map[string]string) *StatefulSet

SetPostStartHTTP set PostStart http style PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*StatefulSet) SetPreStopExec

func (obj *StatefulSet) SetPreStopExec(command []string) *StatefulSet

SetPreStopExec set StatefulSet PreStop command PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*StatefulSet) SetPreStopHTTP

func (obj *StatefulSet) SetPreStopHTTP(scheme URIScheme, host string, port int, path string, headers ...map[string]string) *StatefulSet

SetPreStopHTTP set preStop http style PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

func (*StatefulSet) SetPreferredNodeAffinity

func (obj *StatefulSet) SetPreferredNodeAffinity(weight int32, key string, value []string, operator NodeSelectorOperator) *StatefulSet

SetPreferredNodeAffinity set node affinity for PreferredDuringSchedulingIgnoredDuringExecution style

func (*StatefulSet) SetReplicas

func (obj *StatefulSet) SetReplicas(replicas int32) *StatefulSet

SetReplicas set StatefulSet(sts) replicas default 1

func (*StatefulSet) SetRequiredAndNodeAffinity

func (obj *StatefulSet) SetRequiredAndNodeAffinity(key string, value []string, operator NodeSelectorOperator) *StatefulSet

SetRequiredAndNodeAffinity set node affinity for RequiredDuringSchedulingIgnoredDuringExecution style A list of keys, many key do AND operation.

func (*StatefulSet) SetRequiredORNodeAffinity

func (obj *StatefulSet) SetRequiredORNodeAffinity(key string, value []string, operator NodeSelectorOperator) *StatefulSet

SetRequiredORNodeAffinity set node affinity for RequiredDuringSchedulingIgnoredDuringExecution style A list of keys, many key do OR operation.

func (*StatefulSet) SetResourceLimit

func (obj *StatefulSet) SetResourceLimit(limits map[ResourceName]string) *StatefulSet

SetResourceLimit set container of StatefulSet resource limit,eg:CPU and MEMORY

func (*StatefulSet) SetResourceRequst

func (obj *StatefulSet) SetResourceRequst(requests map[ResourceName]string) *StatefulSet

SetResourceRequst set container of StatefulSet resource request,only CPU and MEMORY

func (*StatefulSet) SetSelector

func (obj *StatefulSet) SetSelector(labels map[string]string) *StatefulSet

SetSelector set StatefulSet(sts) labels selector and set Pod Labels

func (*StatefulSet) SetTCPLiveness

func (obj *StatefulSet) SetTCPLiveness(host string, port int, initDelaySec, timeoutSec, periodSec int32) *StatefulSet

SetTCPLiveness set container liveness of tcp style host: default is "" port: required timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe??defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*StatefulSet) SetTCPReadness

func (obj *StatefulSet) SetTCPReadness(host string, port int, initDelaySec, timeoutSec, periodSec int32) *StatefulSet

SetTCPReadness set container readness of tcp style host: default is "" port: required timeoutSec: http request timeout seconds,defaults to 1 second. Minimum value is 1. periodSec: how often does the probe? defaults to 1 second. Minimum value is 1,Except for the first time? headers: headers[0] is HTTP Header, do not fill if you do not need to set on the other hand, only **first container** will be set livenessProbe

func (*StatefulSet) YAMLNew

func (obj *StatefulSet) YAMLNew(yamlbyts []byte) *StatefulSet

YAMLNew use yaml data create StatefulSet

type StorageClass

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

StorageClass include Kubernetes resource object StorageClass and error.

func NewStorageClass

func NewStorageClass() *StorageClass

NewStorageClass create StorageClass and chain function call begin with this function.

func (*StorageClass) Finish

func (obj *StorageClass) Finish() (*v1.StorageClass, error)

Finish chain function call end with this function return Kubernetes resource object StorageClass and error. In the function, it will check necessary parameters,input the default field.

func (*StorageClass) JSONNew

func (obj *StorageClass) JSONNew(jsonbyte []byte) *StorageClass

JSONNew use json data create StorageClass

func (*StorageClass) SetAnnotations

func (obj *StorageClass) SetAnnotations(annotations map[string]string) *StorageClass

SetAnnotations set storageClass annotations

func (*StorageClass) SetLabels

func (obj *StorageClass) SetLabels(labels map[string]string) *StorageClass

SetLabels set StorageClass labels

func (*StorageClass) SetMountOptions

func (obj *StorageClass) SetMountOptions(opts []string) *StorageClass

SetMountOptions set sorageClass mount Options

func (*StorageClass) SetName

func (obj *StorageClass) SetName() *StorageClass

SetName set storageCLASS name

func (*StorageClass) SetParameters

func (obj *StorageClass) SetParameters(parameters map[string]string) *StorageClass

SetParameters set storageClass parameters

func (*StorageClass) SetProvisioner

func (obj *StorageClass) SetProvisioner(provisioner string) *StorageClass

SetProvisioner set storageClass privisioner

func (*StorageClass) SetReclaimPolicy

func (obj *StorageClass) SetReclaimPolicy(reclaimPolicy PersistentVolumeReclaimPolicy) *StorageClass

SetReclaimPolicy set setReclaim policy

func (*StorageClass) SetVolumeBindingMode

func (obj *StorageClass) SetVolumeBindingMode(bindingMode VolumeBindingMode) *StorageClass

SetVolumeBindingMode set storageClass Volume BindingMode,value only:WaitForFirstConsumer,Immediate

func (*StorageClass) YAMLNew

func (obj *StorageClass) YAMLNew(yamlbyts []byte) *StorageClass

YAMLNew use yaml data create StorageClass

type SubKind

type SubKind string

SubKind subject kind

const (
	User  SubKind = "User"
	Group SubKind = "Group"
	SA    SubKind = "ServiceAccount"
)

subject kinds

type TaintEffect

type TaintEffect string

TaintEffect taint effect type

const (
	// Do not allow new pods to schedule onto the node unless they tolerate the taint,
	// but allow all pods submitted to Kubelet without going through the scheduler
	// to start, and allow all already-running pods to continue running.
	// Enforced by the scheduler.
	TaintEffectNoSchedule TaintEffect = "NoSchedule"
	// Like TaintEffectNoSchedule, but the scheduler tries not to schedule
	// new pods onto the node, rather than prohibiting new pods from scheduling
	// onto the node entirely. Enforced by the scheduler.
	TaintEffectPreferNoSchedule TaintEffect = "PreferNoSchedule"

	// Evict any already-running pods that do not tolerate the taint.
	// Currently enforced by NodeController.
	TaintEffectNoExecute TaintEffect = "NoExecute"
)

Taint Effects only NoSchedule,PreferNoSchedule,NoExecute

func (TaintEffect) ToK8s

func (te TaintEffect) ToK8s() v1.TaintEffect

ToK8s local TaintEffect to kubernetes TaintEffect

type TolerationOperator

type TolerationOperator string

TolerationOperator A toleration operator is the set of operators that can be used in a toleration.

const (
	TolerationOpExists TolerationOperator = "Exists"
	TolerationOpEqual  TolerationOperator = "Equal"
)

TolerationOperator operators

func (TolerationOperator) ToK8s

ToK8s local TolerationOperator to kubernetes TolerationOperator

type URIScheme

type URIScheme string

URIScheme identifies the scheme used for connection to a host for Get actions

const (
	// URISchemeHTTP means that the scheme used will be http://
	URISchemeHTTP URIScheme = "HTTP"
	// URISchemeHTTPS means that the scheme used will be https://
	URISchemeHTTPS URIScheme = "HTTPS"
)

type UnionPV

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

UnionPV output pvc and pv

func NewUnionPV

func NewUnionPV() *UnionPV

NewUnionPV create PersistentVolume,PersistentVolumeClaim and error and chain function call begin with this function.

func (*UnionPV) Finish

func (un *UnionPV) Finish() (pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim, err error)

Finish Chain function call end with this function return Kubernetes resource object(PersistentVolume,PersistentVolumeClaim) and error In the function, it will check necessary parametersainput the default field

func (*UnionPV) Release

func (un *UnionPV) Release() (pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim, err error)

Release release UnionPV on Kubernetes

func (*UnionPV) SetAccessMode

func (un *UnionPV) SetAccessMode(mode PersistentVolumeAccessMode) *UnionPV

SetAccessMode set PersistentVolume and PersistentVolumeClaim accessmode

func (*UnionPV) SetAccessModes

func (un *UnionPV) SetAccessModes(modes []PersistentVolumeAccessMode) *UnionPV

SetAccessModes PersistentVolume and PersistentVolumeClaim access modes

func (*UnionPV) SetAnnotations

func (un *UnionPV) SetAnnotations(annotations map[string]string) *UnionPV

SetAnnotations get PersistentVolume and PersistentVolumeClaim annotations

func (*UnionPV) SetCapacity

func (un *UnionPV) SetCapacity(capMaps map[ResourceName]string) *UnionPV

SetCapacity set PersistentVolume capacity and set PersistentVolumeClaim resource request

func (*UnionPV) SetLabels

func (un *UnionPV) SetLabels(labels map[string]string) *UnionPV

SetLabels set PersistentVolume labels ,set PersistentVolumeClaim labels and set PersistentVolumeClaim selector

func (*UnionPV) SetNFS

func (un *UnionPV) SetNFS(nfs *NFSVolumeSource) *UnionPV

SetNFS set PersistentVolume volume source is NFS

func (*UnionPV) SetName

func (un *UnionPV) SetName(name string) *UnionPV

SetName set PersistentVolume and PersistentVolumeClaim name

func (*UnionPV) SetNamespace

func (un *UnionPV) SetNamespace(namespace string) *UnionPV

SetNamespace set PersistentVolumeClaim namespace, and PersistentVolume can't set namespece because of no such attribute

func (*UnionPV) SetNamespaceAndName

func (un *UnionPV) SetNamespaceAndName(namespace, name string) *UnionPV

SetNamespaceAndName set PersistentVolumeClaim namespace and name, set PersistentVolumeClaim name PersistentVolume can't set namespece because of no such attribute

func (*UnionPV) SetRBD

func (un *UnionPV) SetRBD(rbd *RBDPersistentVolumeSource) *UnionPV

SetRBD set PersistentVolume volume source is RBD

func (*UnionPV) SetVolumeMode

func (un *UnionPV) SetVolumeMode(volumeMode PersistentVolumeMode) *UnionPV

SetVolumeMode set pvc volume mode Filesystem or Block

type VolumeBindingMode

type VolumeBindingMode string

VolumeBindingMode indicates how PersistentVolumeClaims should be bound.

const (
	// VolumeBindingImmediate indicates that PersistentVolumeClaims should be
	// immediately provisioned and bound.  This is the default mode.
	VolumeBindingImmediate VolumeBindingMode = "Immediate"

	// VolumeBindingWaitForFirstConsumer indicates that PersistentVolumeClaims
	// should not be provisioned and bound until the first Pod is created that
	// references the PeristentVolumeClaim.  The volume provisioning and
	// binding will occur during Pod scheduing.
	VolumeBindingWaitForFirstConsumer VolumeBindingMode = "WaitForFirstConsumer"
)

func (VolumeBindingMode) ToK8s

ToK8s local bindingMode to kubernetes bindingMode

Jump to

Keyboard shortcuts

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