Documentation ¶
Index ¶
- Constants
- func APIGroupMatches(rule *rbacv1.PolicyRule, requestedGroup string) bool
- func AddLabel(labels map[string]string, labelKey, labelValue string) map[string]string
- func AddOwnersLabel(owners, resource, name, namespace string) string
- func AppendErrors(errsList ...[]error) []error
- func ApplyClusterRole(kubeClient kubernetes.Interface, requiredClusterrole *rbacv1.ClusterRole) error
- func ApplyClusterRoleBinding(ctx context.Context, kubeClient kubernetes.Interface, ...) error
- func ApplyRoleBinding(ctx context.Context, kubeClient kubernetes.Interface, ...) error
- func BuildKubeClient(kubeConfigPath string) (*kubernetes.Clientset, error)
- func CloneAndAddLabel(labels map[string]string, labelKey, labelValue string) map[string]string
- func ClusterIsOffLine(conditions []metav1.Condition) bool
- func ContainsString(slice []string, s string) bool
- func ConvertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error)
- func DeleteClusterRole(kubeClient kubernetes.Interface, clusterRoleName string) error
- func EncodeCertPEM(cert *x509.Certificate) []byte
- func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte
- func EqualSubjects(subjects1, subjects2 []rbacv1.Subject) bool
- func FormatQuatityToGi(q resource.Quantity) resource.Quantity
- func FormatQuatityToMi(q resource.Quantity) resource.Quantity
- func GenerateClusterRoleName(clusterName, role string) string
- func GenerateClustersetClusterRoleBindingName(clusterName, role string) string
- func GenerateClustersetClusterroleName(clustersetName, role string) string
- func GenerateClustersetResourceRoleBindingName(role string) string
- func GeneratePemFile(dir, certFile, keyFile string) (string, error)
- func GetAdminResourceFromClusterRole(clusterRole *rbacv1.ClusterRole, group, resource string) (sets.String, bool)
- func GetCAFromApiserver(ctx context.Context, ocpClient openshiftclientset.Interface, ...) ([]byte, error)
- func GetCAFromConfigMap(ctx context.Context, kubeClient kubernetes.Interface) ([]byte, error)
- func GetCAFromServiceAccount(ctx context.Context, kubeClient kubernetes.Interface) ([]byte, error)
- func GetCPUAndMemoryAllocation(pods []*corev1.Pod) (cpuAllocation, memoryAllocation resource.Quantity)
- func GetCPUAndMemoryCapacity(nodes []*corev1.Node) (cpuCapacity, memoryCapacity resource.Quantity)
- func GetComponentNamespace() (string, error)
- func GetKubeAPIServerAddress(ctx context.Context, openshiftClient openshiftclientset.Interface) (string, error)
- func GetStorageCapacityAndAllocation(pvs []*corev1.PersistentVolume) (storageCapacity, storageAllocation resource.Quantity)
- func GetViewResourceFromClusterRole(clusterRole *rbacv1.ClusterRole, group, resource string) (sets.String, bool)
- func IsManagedClusterClusterrolebinding(clusterrolebindingName, role string) bool
- func MatchLabelForLabelSelector(targetLabels map[string]string, labelSelector *metav1.LabelSelector) bool
- func MergeMap(modified *bool, existing *map[string]string, required map[string]string)
- func Mergesubjects(subjects []rbacv1.Subject, cursubjects []rbacv1.Subject) []rbacv1.Subject
- func NewMultiLineAggregate(errList []error) error
- func NewPrivateKey() (*rsa.PrivateKey, error)
- func NewSignedCert(cfg cert.Config, key crypto.Signer, caCert *x509.Certificate, ...) (*x509.Certificate, error)
- func PodRequestsAndLimits(pod *corev1.Pod) (reqs map[corev1.ResourceName]resource.Quantity, ...)
- func RemoveString(slice []string, s string) (result []string)
- func ResourceMatches(rule *rbacv1.PolicyRule, ...) bool
- func ResourceNamespacedName(resourceType, namespace, name string) string
- func StringToMap(str string) map[string]string
- func SyncMapField(modified *bool, existing *map[string]string, required map[string]string, ...)
- func VerbMatches(rule *rbacv1.PolicyRule, requestedVerb string) bool
- func WriteKeyCertToFile(certDir string, key, cert []byte) (string, error)
Constants ¶
const ( ApiserverConfigName = "cluster" OpenshiftConfigNamespace = "openshift-config" ServiceAccountNamespace = "kube-system" ServiceAccountName = "default" ConfigmapNamespace = "kube-public" CrtConfigmapName = "kube-root-ca.crt" ClusterinfoConfigmap = "cluster-info" )
Variables ¶
This section is empty.
Functions ¶
func APIGroupMatches ¶
func APIGroupMatches(rule *rbacv1.PolicyRule, requestedGroup string) bool
func AddOwnersLabel ¶
func AppendErrors ¶
appendErrors append errs, return appended result
func ApplyClusterRole ¶
func ApplyClusterRole(kubeClient kubernetes.Interface, requiredClusterrole *rbacv1.ClusterRole) error
apply cluster role
func ApplyClusterRoleBinding ¶
func ApplyClusterRoleBinding(ctx context.Context, kubeClient kubernetes.Interface, required *rbacv1.ClusterRoleBinding) error
ApplyClusterRoleBinding merges objectmeta, requires subjects and role refs
func ApplyRoleBinding ¶
func ApplyRoleBinding(ctx context.Context, kubeClient kubernetes.Interface, required *rbacv1.RoleBinding) error
ApplyRoleBinding merges objectmeta, requires subjects and role refs
func BuildKubeClient ¶
func BuildKubeClient(kubeConfigPath string) (*kubernetes.Clientset, error)
func CloneAndAddLabel ¶
CloneAndAddLabel the given map and returns a new map with the given key and value added. Returns the given map, if labelKey is empty.
func ClusterIsOffLine ¶
func ContainsString ¶
ContainsString to check string from a slice of strings.
func ConvertLabels ¶
func ConvertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error)
ConvertLabels returns label
func DeleteClusterRole ¶
func DeleteClusterRole(kubeClient kubernetes.Interface, clusterRoleName string) error
Delete cluster role
func EncodeCertPEM ¶
func EncodeCertPEM(cert *x509.Certificate) []byte
EncodeCertPEM returns PEM-endcoded certificate data
func EncodePrivateKeyPEM ¶
func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte
EncodePrivateKeyPEM returns PEM-encoded private key data
func EqualSubjects ¶
func GenerateClusterRoleName ¶
managedcluster admin role
func GenerateClustersetClusterRoleBindingName ¶
clusterset clusterrolebinding
func GenerateClustersetResourceRoleBindingName ¶
clusterset resource rolebinding name
func GeneratePemFile ¶
GeneratePemFile generate a pem file that include key and cert
func GetAdminResourceFromClusterRole ¶
func GetAdminResourceFromClusterRole(clusterRole *rbacv1.ClusterRole, group, resource string) (sets.String, bool)
GetViewResourceFromClusterRole match the "update" permission of resource, which means this role has admin permission to this resource
func GetCAFromApiserver ¶
func GetCAFromApiserver(ctx context.Context, ocpClient openshiftclientset.Interface, kubeClient kubernetes.Interface, kubeAPIServer string) ([]byte, error)
func GetCAFromConfigMap ¶
GetCACert returns the CA cert. It searches in the kube-root-ca.crt configmap in kube-public ns.
func GetCAFromServiceAccount ¶
func GetCPUAndMemoryCapacity ¶
func GetComponentNamespace ¶
func GetKubeAPIServerAddress ¶
func GetStorageCapacityAndAllocation ¶
func GetStorageCapacityAndAllocation(pvs []*corev1.PersistentVolume) (storageCapacity, storageAllocation resource.Quantity)
func GetViewResourceFromClusterRole ¶
func GetViewResourceFromClusterRole(clusterRole *rbacv1.ClusterRole, group, resource string) (sets.String, bool)
GetViewResourceFromClusterRole match the "get" permission of resource, which means this role has view permission to this resource
func MatchLabelForLabelSelector ¶
func MatchLabelForLabelSelector(targetLabels map[string]string, labelSelector *metav1.LabelSelector) bool
MatchLabelForLabelSelector match labels for labelselector, if labelSelecor is nil, select everything
func Mergesubjects ¶
func NewMultiLineAggregate ¶
NewMultiLineAggregate returns an aggregate error with multi-line output
func NewPrivateKey ¶
func NewPrivateKey() (*rsa.PrivateKey, error)
NewPrivateKey creates an RSA private key
func NewSignedCert ¶
func NewSignedCert(cfg cert.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error)
NewSignedCert creates a signed certificate using the given CA certificate and key
func PodRequestsAndLimits ¶
func PodRequestsAndLimits( pod *corev1.Pod) (reqs map[corev1.ResourceName]resource.Quantity, limits map[corev1.ResourceName]resource.Quantity)
PodRequestsAndLimits returns a dictionary of all defined resources summed up for all containers of the pod.
func RemoveString ¶
ContainsString to remove string from a slice of strings.
func ResourceMatches ¶
func ResourceMatches(rule *rbacv1.PolicyRule, combinedRequestedResource, requestedSubresource string) bool
func ResourceNamespacedName ¶
func SyncMapField ¶
func SyncMapField(modified *bool, existing *map[string]string, required map[string]string, syncFiledKey string)
SyncMapField sync the "syncFiledKey" label filed of required map.
func VerbMatches ¶
func VerbMatches(rule *rbacv1.PolicyRule, requestedVerb string) bool
Types ¶
This section is empty.