Documentation ¶
Overview ¶
Package k8s provides interfaces, types and functions for k8s related utilities.
Index ¶
- Constants
- func AddDefaultAppLabels(appInstanceName string, labels map[string]string) map[string]string
- func GetDefaultAppLabels(appInstanceName string) map[string]string
- type Resource
- type ResourceManager
- func (r ResourceManager) CSIDriver(name string, labels map[string]string, spec *storagev1beta1.CSIDriverSpec) *resource.CSIDriver
- func (r ResourceManager) ClusterRole(name string, labels map[string]string, rules []rbacv1.PolicyRule) *resource.ClusterRole
- func (r ResourceManager) ClusterRoleBinding(name string, labels map[string]string, subjects []rbacv1.Subject, ...) *resource.ClusterRoleBinding
- func (r ResourceManager) ConfigMap(name, namespace string, labels map[string]string, data map[string]string) *resource.ConfigMap
- func (r ResourceManager) DaemonSet(name, namespace string, labels map[string]string, spec *appsv1.DaemonSetSpec) *resource.DaemonSet
- func (r ResourceManager) Deployment(name, namespace string, labels map[string]string, spec *appsv1.DeploymentSpec) *resource.Deployment
- func (r *ResourceManager) GetLabels() map[string]string
- func (r ResourceManager) Ingress(name, namespace string, labels map[string]string, ...) *resource.Ingress
- func (r ResourceManager) PersistentVolumeClaim(name, namespace string, labels map[string]string, ...) *resource.PVC
- func (r ResourceManager) Role(name, namespace string, labels map[string]string, rules []rbacv1.PolicyRule) *resource.Role
- func (r ResourceManager) RoleBinding(name, namespace string, labels map[string]string, subjects []rbacv1.Subject, ...) *resource.RoleBinding
- func (r ResourceManager) Secret(name, namespace string, labels map[string]string, secType corev1.SecretType, ...) *resource.Secret
- func (r ResourceManager) Service(name, namespace string, labels map[string]string, ...) *resource.Service
- func (r ResourceManager) ServiceAccount(name, namespace string, labels map[string]string) *resource.ServiceAccount
- func (r *ResourceManager) SetLabels(labels map[string]string) *ResourceManager
- func (r ResourceManager) StatefulSet(name, namespace string, labels map[string]string, spec *appsv1.StatefulSetSpec) *resource.StatefulSet
- func (r ResourceManager) StorageClass(name string, labels map[string]string, provisioner string, ...) *resource.StorageClass
Constants ¶
const ( AppName = "app.kubernetes.io/name" AppInstance = "app.kubernetes.io/instance" AppVersion = "app.kubernetes.io/version" AppComponent = "app.kubernetes.io/component" AppPartOf = "app.kubernetes.io/part-of" AppManagedBy = "app.kubernetes.io/managed-by" ServiceFor = "app.kubernetes.io/service-for" )
k8s recommended labels from https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ .
Custom labels:
- app.kubernetes.io/service-for: This label should be used to differentiate
between services by specifying what type of endpoint a service provides, like nfs-server or metrics endpoint. This can be used along with component label to uniquely select services by service label selectors, e.g. prometheus service monitor selector.
Variables ¶
This section is empty.
Functions ¶
func AddDefaultAppLabels ¶
AddDefaultAppLabels adds the default app labels to given labels.
func GetDefaultAppLabels ¶
GetDefaultAppLabels returns the default k8s app labels for resources created by the operator. appInstanceName should be the name of the StorageOSCluster object.
Types ¶
type Resource ¶
type Resource interface { // Get tries to get an existing resource if any, else returns an error. Get() (interface{}, error) // Create creates the resource. Create() error // Delete deletes the resource. Delete() error }
Resource is an interface for k8s resources. All the k8s resources supported by this package must implement this interface.
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager is k8s resource manager. It provides methods to easily manage k8s resources.
func NewResourceManager ¶
func NewResourceManager(client client.Client) *ResourceManager
NewResourceManager returns an initialized k8s ResourceManager.
func (ResourceManager) CSIDriver ¶
func (r ResourceManager) CSIDriver(name string, labels map[string]string, spec *storagev1beta1.CSIDriverSpec) *resource.CSIDriver
CSIDriver returns a CSIDriver object.
func (ResourceManager) ClusterRole ¶
func (r ResourceManager) ClusterRole(name string, labels map[string]string, rules []rbacv1.PolicyRule) *resource.ClusterRole
ClusterRole returns a ClusterRole object.
func (ResourceManager) ClusterRoleBinding ¶
func (r ResourceManager) ClusterRoleBinding(name string, labels map[string]string, subjects []rbacv1.Subject, roleRef *rbacv1.RoleRef) *resource.ClusterRoleBinding
ClusterRoleBinding returns a ClusterRoleBinding object.
func (ResourceManager) ConfigMap ¶
func (r ResourceManager) ConfigMap(name, namespace string, labels map[string]string, data map[string]string) *resource.ConfigMap
ConfigMap returns a ConfigMap object. This can also be used to delete an existing object without any references to the actual object. The name and namespace, without data, can be used to refer the object and perform operations on it.
func (ResourceManager) DaemonSet ¶
func (r ResourceManager) DaemonSet(name, namespace string, labels map[string]string, spec *appsv1.DaemonSetSpec) *resource.DaemonSet
DaemonSet returns a DaemonSet object.
func (ResourceManager) Deployment ¶
func (r ResourceManager) Deployment(name, namespace string, labels map[string]string, spec *appsv1.DeploymentSpec) *resource.Deployment
Deployment returns a Deployment object.
func (*ResourceManager) GetLabels ¶
func (r *ResourceManager) GetLabels() map[string]string
GetLabels returns labels of the resource manager.
func (ResourceManager) Ingress ¶
func (r ResourceManager) Ingress(name, namespace string, labels map[string]string, annotations map[string]string, spec *extensionsv1beta1.IngressSpec) *resource.Ingress
Ingress returns an Ingress object.
func (ResourceManager) PersistentVolumeClaim ¶
func (r ResourceManager) PersistentVolumeClaim(name, namespace string, labels map[string]string, spec *corev1.PersistentVolumeClaimSpec) *resource.PVC
PersistentVolumeClaim returns a PersistentVolumeClaim object.
func (ResourceManager) Role ¶
func (r ResourceManager) Role(name, namespace string, labels map[string]string, rules []rbacv1.PolicyRule) *resource.Role
Role returns a Role object.
func (ResourceManager) RoleBinding ¶
func (r ResourceManager) RoleBinding(name, namespace string, labels map[string]string, subjects []rbacv1.Subject, roleRef *rbacv1.RoleRef) *resource.RoleBinding
RoleBinding returns a RoleBinding object.
func (ResourceManager) Secret ¶
func (r ResourceManager) Secret(name, namespace string, labels map[string]string, secType corev1.SecretType, data map[string][]byte) *resource.Secret
Secret returns a Secret object.
func (ResourceManager) Service ¶
func (r ResourceManager) Service(name, namespace string, labels map[string]string, annotations map[string]string, spec *corev1.ServiceSpec) *resource.Service
Service returns a Service object.
func (ResourceManager) ServiceAccount ¶
func (r ResourceManager) ServiceAccount(name, namespace string, labels map[string]string) *resource.ServiceAccount
ServiceAccount returns a ServiceAccount object.
func (*ResourceManager) SetLabels ¶
func (r *ResourceManager) SetLabels(labels map[string]string) *ResourceManager
SetLabels sets a label for the resources created by the resource manager.
func (ResourceManager) StatefulSet ¶
func (r ResourceManager) StatefulSet(name, namespace string, labels map[string]string, spec *appsv1.StatefulSetSpec) *resource.StatefulSet
StatefulSet returns a StatefulSet object.
func (ResourceManager) StorageClass ¶
func (r ResourceManager) StorageClass(name string, labels map[string]string, provisioner string, params map[string]string) *resource.StorageClass
StorageClass returns a StorageClass object.