Documentation ¶
Overview ¶
Package k8s abstracts all Kubernetes specific behaviour
Index ¶
- Constants
- func AnnotateNodeCIDR(c kubernetes.Interface, nodeName string, v4CIDR, v6CIDR *net.IPNet) error
- func CreateClient(config *rest.Config) (*kubernetes.Clientset, error)
- func CreateConfig(endpoint, kubeCfgPath string) (*rest.Config, error)
- func CreateTPRClient(config *rest.Config) (*rest.RESTClient, error)
- func ExtractNamespace(np *metav1.ObjectMeta) string
- func ExtractPolicyName(np *networkingv1.NetworkPolicy) string
- func GetNode(c kubernetes.Interface, nodeName string) (*v1.Node, error)
- func ParseNetworkPolicy(np *networkingv1.NetworkPolicy) (api.Rules, error)
- func ParseNode(k8sNode *v1.Node) *node.Node
- type CiliumNetworkPolicy
- type CiliumNetworkPolicyList
Constants ¶
const ( // ThirdPartyResourceGroup is the name of the third party resource group ThirdPartyResourceGroup = "cilium.io" // ThirdPartyResourceVersion is the current version of the resource ThirdPartyResourceVersion = "v1" )
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
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
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
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
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
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