k8s

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package k8s abstracts all Kubernetes specific behaviour

Index

Constants

View Source
const (
	// ThirdPartyResourceGroup is the name of the third party resource group
	ThirdPartyResourceGroup = "cilium.io"

	// ThirdPartyResourceVersion is the current version of the resource
	ThirdPartyResourceVersion = "v1"
)
View Source
const (
	// AnnotationName is an optional annotation to the NetworkPolicy
	// resource which specifies the name of the policy node to which all
	// rules should be applied to.
	AnnotationName = "io.cilium.name"

	// Annotationv4CIDRName is the annotation name used to store the IPv4
	// pod CIDR in the node's annotations.
	Annotationv4CIDRName = "io.cilium.network.ipv4-pod-cidr"
	// Annotationv6CIDRName is the annotation name used to store the IPv6
	// pod CIDR in the node's annotations.
	Annotationv6CIDRName = "io.cilium.network.ipv6-pod-cidr"

	// EnvNodeNameSpec is the environment label used by Kubernetes to
	// specify the node's name.
	EnvNodeNameSpec = "K8S_NODE_NAME"

	// PolicyLabelName is the name of the policy label which refers to the
	// k8s policy name
	PolicyLabelName = "io.cilium.k8s-policy-name"
	// PodNamespaceLabel is the label used in kubernetes containers to
	// specify which namespace they belong to.
	PodNamespaceLabel = types.KubernetesPodNamespaceLabel
	// PodNamespaceMetaLabels is the label used to store the labels of the
	// kubernetes namespace's labels.
	PodNamespaceMetaLabels = "ns-labels"
)

Variables

This section is empty.

Functions

func AnnotateNodeCIDR added in v0.10.0

func AnnotateNodeCIDR(c kubernetes.Interface, nodeName string, v4CIDR, v6CIDR *net.IPNet) error

AnnotateNodeCIDR writes both v4 and v6 CIDRs in the given k8s node name. In case of failure while updating the node, this function while spawn a go routine to retry the node update indefinitely.

func CreateClient added in v0.10.0

func CreateClient(config *rest.Config) (*kubernetes.Clientset, error)

CreateClient creates a new client to access the Kubernetes API

func CreateConfig added in v0.10.0

func CreateConfig(endpoint, kubeCfgPath string) (*rest.Config, error)

CreateConfig creates a rest.Config for a given endpoint using a kubeconfig file.

func CreateTPRClient added in v0.10.0

func CreateTPRClient(config *rest.Config) (*rest.RESTClient, error)

CreateTPRClient creates a new k8s client for third party resources

func ExtractNamespace added in v0.10.0

func ExtractNamespace(np *metav1.ObjectMeta) string

ExtractNamespace extracts the namespace of ObjectMeta.

func ExtractPolicyName added in v0.10.0

func ExtractPolicyName(np *networkingv1.NetworkPolicy) string

ExtractPolicyName extracts the name of policy name

func GetNode added in v0.10.0

func GetNode(c kubernetes.Interface, nodeName string) (*v1.Node, error)

GetNode returns the kubernetes nodeName's node information from the kubernetes api server

func ParseNetworkPolicy added in v0.10.0

func ParseNetworkPolicy(np *networkingv1.NetworkPolicy) (api.Rules, error)

ParseNetworkPolicy parses a k8s NetworkPolicy and returns a list of Cilium policy rules that can be added

func ParseNode added in v0.10.0

func ParseNode(k8sNode *v1.Node) *node.Node

ParseNode parses a kubernetes node to a cilium node

Types

type CiliumNetworkPolicy added in v0.10.0

type CiliumNetworkPolicy struct {
	metav1.TypeMeta `json:",inline"`
	// +optional
	Metadata metav1.ObjectMeta `json:"metadata"`

	// Spec is the desired Cilium specific rule specification.
	Spec *api.Rule `json:"spec,omitempty"`

	// Specs is a list of desired Cilium specific rule specification.
	Specs api.Rules `json:"specs,omitempty"`
}

CiliumNetworkPolicy is a Kubernetes third-party resource with an extended version of NetworkPolicy

func (*CiliumNetworkPolicy) GetObjectKind added in v0.10.0

func (r *CiliumNetworkPolicy) GetObjectKind() schema.ObjectKind

GetObjectKind returns the kind of the object

func (*CiliumNetworkPolicy) GetObjectMeta added in v0.10.0

func (r *CiliumNetworkPolicy) GetObjectMeta() metav1.Object

GetObjectMeta returns the metadata of the object

func (*CiliumNetworkPolicy) Parse added in v0.10.0

func (r *CiliumNetworkPolicy) Parse() (api.Rules, error)

Parse parses a CiliumNetworkPolicy and returns a list of cilium policy rules.

type CiliumNetworkPolicyList added in v0.10.0

type CiliumNetworkPolicyList struct {
	metav1.TypeMeta `json:",inline"`
	// +optional
	Metadata metav1.ListMeta `json:"metadata"`

	// Items is a list of CiliumNetworkPolicy
	Items []CiliumNetworkPolicy `json:"items"`
}

CiliumNetworkPolicyList is a list of CiliumNetworkPolicy objects

func (*CiliumNetworkPolicyList) GetListMeta added in v0.10.0

func (r *CiliumNetworkPolicyList) GetListMeta() metav1.List

GetListMeta returns the metadata of the object

func (*CiliumNetworkPolicyList) GetObjectKind added in v0.10.0

func (r *CiliumNetworkPolicyList) GetObjectKind() schema.ObjectKind

GetObjectKind returns the kind of the object

Jump to

Keyboard shortcuts

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