clientgo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DepInstaller   = "dep-installer-job"
	Dep            = "nocalhost-dep"
	NocalhostLabel = "nocalhost-managed"
	Api            = "nocalhost-api"
)

Variables

View Source
var LimitedRules = &rbacv1.PolicyRule{
	Verbs:     []string{"get", "list"},
	Resources: []string{"resourcequotas", "roles"},
	APIGroups: []string{"*"},
}

Functions

This section is empty.

Types

type GoClient

type GoClient struct {
	DynamicClient dynamic.Interface

	Config []byte
	// contains filtered or unexported fields
}

func NewAdminGoClient

func NewAdminGoClient(kubeconfig []byte) (*GoClient, error)

new client with time out

func NewAdminGoClientWithTimeout

func NewAdminGoClientWithTimeout(kubeconfig []byte, duration time.Duration) (*GoClient, error)

func NewGoClient

func NewGoClient(kubeconfig []byte) (*GoClient, error)

func (*GoClient) AppendClusterRoleBinding

func (c *GoClient) AppendClusterRoleBinding(name, role, toServiceAccount, toServiceAccountNs string) error

create roleBinding role=admin

func (*GoClient) AppendRoleBinding

func (c *GoClient) AppendRoleBinding(name, namespace, role, toServiceAccount, toServiceAccountNs string) error

create roleBinding role=admin

func (*GoClient) Apply

func (c *GoClient) Apply(object interface{}) (*unstructured.Unstructured, error)

func (*GoClient) ApplyForce

func (c *GoClient) ApplyForce(object interface{}) (*unstructured.Unstructured, error)

func (*GoClient) CheckIstio

func (c *GoClient) CheckIstio() (bool, error)

func (*GoClient) CreateClusterRole

func (c *GoClient) CreateClusterRole(name string, rule []rbacv1.PolicyRule) (bool, error)

cluster admin role for nocalhost

func (*GoClient) CreateClusterRoleBinding

func (c *GoClient) CreateClusterRoleBinding(name, namespace, role, toServiceAccount string) (bool, error)

create clusterRoleBinding role=admin

func (*GoClient) CreateConfigMap

func (c *GoClient) CreateConfigMap(namespace string, configmap *corev1.ConfigMap) (*corev1.ConfigMap, error)

func (*GoClient) CreateConfigMapWithValue

func (c *GoClient) CreateConfigMapWithValue(name, namespace, key, value string) (bool, error)

Initial admin kubeconfig in cluster for admission webhook

func (*GoClient) CreateDeployment

func (c *GoClient) CreateDeployment(namespace string, deployment *v1.Deployment) (*v1.Deployment, error)

func (*GoClient) CreateLimitRange

func (c *GoClient) CreateLimitRange(name, namespace, reqMem, limitsMem, reqCpu, limitsCpu, ephemeralStorage string) (
	bool, error,
)

CreateLimitRange create default resource quota for container

func (*GoClient) CreateNS

func (c *GoClient) CreateNS(namespace string, labels map[string]string) (bool, error)

When create sub namespace for developer, label should set "nocalhost" for nocalhost-dep admission webhook muting when create nocalhost-reserved namesapce, label should set "nocalhost-reserved"

func (*GoClient) CreateNocalhostPriorityClass

func (c *GoClient) CreateNocalhostPriorityClass() error

deploy priorityclass

func (*GoClient) CreateResourceQuota

func (c *GoClient) CreateResourceQuota(
	name, namespace, reqMem, reqCpu, limitsMem,
	limitsCpu, storageCapacity, ephemeralStorage, pvcCount, lbCount string,
) (
	bool, error,
)

CreateResourceQuota Initial resource quota for namespace

func (*GoClient) CreateRole

func (c *GoClient) CreateRole(name, namespace string) (bool, error)

create user role for single namespace name default nocalhost-role

default create every developer can access all resource for he's namespace

func (*GoClient) CreateRoleBinding

func (c *GoClient) CreateRoleBinding(name, namespace, role, toServiceAccount string) (bool, error)

CreateRoleBinding bind roles for serviceAccount this use for given default serviceAccount default:view case by initContainer need use kubectl get pods....(clusterRole=view) and this will use for bind developer serviceAccount roles(clusterRole=nocalhost-roles)

func (*GoClient) CreateSecret

func (c *GoClient) CreateSecret(namespace string, secret *corev1.Secret) (*corev1.Secret, error)

func (*GoClient) CreateService

func (c *GoClient) CreateService(namespace string, service *corev1.Service) (*corev1.Service, error)

func (*GoClient) CreateServiceAccount

func (c *GoClient) CreateServiceAccount(name, namespace string) (bool, error)

CreateServiceAccount for namespace(Authorization cluster for developer)

func (*GoClient) CreateVirtualService

func (c *GoClient) CreateVirtualService(namespace string,
	vs *v1alpha3.VirtualService) (*v1alpha3.VirtualService, error)

func (*GoClient) Delete

func (c *GoClient) Delete(object interface{}) error

func (*GoClient) DeleteConfigMap

func (c *GoClient) DeleteConfigMap(namespace string, configmap *corev1.ConfigMap) (*corev1.ConfigMap, error)

func (*GoClient) DeleteDeployment

func (c *GoClient) DeleteDeployment(namespace, name string) error

func (*GoClient) DeleteJob

func (c *GoClient) DeleteJob(namespace, name string) error

func (*GoClient) DeleteLimitRange

func (c *GoClient) DeleteLimitRange(name, namespace string) (bool, error)

func (*GoClient) DeleteNS

func (c *GoClient) DeleteNS(namespace string) (bool, error)

delete namespace, this will delete all resource in namespace

func (*GoClient) DeletePod

func (c *GoClient) DeletePod(namespace, name string) error

func (*GoClient) DeleteResourceQuota

func (c *GoClient) DeleteResourceQuota(name, namespace string) (bool, error)

func (*GoClient) DeleteSecret

func (c *GoClient) DeleteSecret(namespace string, name string) error

func (*GoClient) DeleteService

func (c *GoClient) DeleteService(namespace, name string) error

func (*GoClient) DeleteServiceAccount

func (c *GoClient) DeleteServiceAccount(name, namespace string) error

func (*GoClient) DeleteVirtualService

func (c *GoClient) DeleteVirtualService(namespace, name string) error

func (*GoClient) DeployNocalhostDep

func (c *GoClient) DeployNocalhostDep(namespace, serviceAccount, tag string) (bool, error)

deploy nocalhost-dep now all value has set by default TODO this might better read from database manifest

func (*GoClient) DeployPrePullImages

func (c *GoClient) DeployPrePullImages(images []string, namespace string) (bool, error)

deploy pre pull images use DaemonSet InitContainer make sure every Node pull images https://kubernetes.io/zh/docs/concepts/workloads/controllers/daemonset/ when started it should kill himself

func (*GoClient) ExistClusterRoleBinding

func (c *GoClient) ExistClusterRoleBinding(roleBinding string) (bool, *rbacv1.ClusterRoleBinding)

func (*GoClient) ExistDeployment

func (c *GoClient) ExistDeployment(namespace, deployment string) (bool, *apiappsV1.Deployment)

func (*GoClient) ExistNs

func (c *GoClient) ExistNs(namespace string) (bool, *corev1.Namespace)

func (*GoClient) ExistPriorityClass

func (c *GoClient) ExistPriorityClass(name string) (bool, *schedulingv1.PriorityClass)

func (*GoClient) ExistServiceAccount

func (c *GoClient) ExistServiceAccount(namespace, name string) (bool, *corev1.ServiceAccount)

func (*GoClient) GenerateNsName

func (c *GoClient) GenerateNsName(userId uint64) string

nocalhost create namespace use the rule: nocal+userId+4 random word, exp: nocal4esac namespace rules must match DNS-1123 label, capital doesn't allow

func (*GoClient) GetClientSet

func (c *GoClient) GetClientSet() *kubernetes.Clientset

func (*GoClient) GetClusterNode

func (c *GoClient) GetClusterNode() (*corev1.NodeList, error)

Get cluster node

func (*GoClient) GetClusterRoleBinding

func (c *GoClient) GetClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)

func (*GoClient) GetClusterVersion

func (c *GoClient) GetClusterVersion() (*version.Info, error)

Get cluster version

func (*GoClient) GetConfigMap

func (c *GoClient) GetConfigMap(namespace, name string) (*corev1.ConfigMap, error)

func (*GoClient) GetConfigMapList

func (c *GoClient) GetConfigMapList(namespace string) (*corev1.ConfigMapList, error)

GetConfigMapList get a list of configmaps.

func (*GoClient) GetDepDeploymentStatus

func (c *GoClient) GetDepDeploymentStatus() error

get deployment

func (*GoClient) GetDeployment

func (c *GoClient) GetDeployment(namespace, name string) (*v1.Deployment, error)

func (*GoClient) GetDeploymentList

func (c *GoClient) GetDeploymentList(namespace string) (*v1.DeploymentList, error)

GetDeploymentList get a list of deployments.

func (*GoClient) GetDiscoveryClient

func (c *GoClient) GetDiscoveryClient() (*discovery.DiscoveryClient, error)

func (*GoClient) GetDiscoveryRESTMapper

func (c *GoClient) GetDiscoveryRESTMapper() (*restmapper.DeferredDiscoveryRESTMapper, error)

func (*GoClient) GetNamespace

func (c *GoClient) GetNamespace(namespace string) (*corev1.Namespace, error)

func (*GoClient) GetRestClient

func (c *GoClient) GetRestClient() (*restclient.RESTClient, error)

func (*GoClient) GetSecret

func (c *GoClient) GetSecret(namespace, name string) (*corev1.Secret, error)

func (*GoClient) GetSecretList

func (c *GoClient) GetSecretList(namespace string) (*corev1.SecretList, error)

GetSecretList get a list of secrets.

func (*GoClient) GetSecretListByType

func (c *GoClient) GetSecretListByType(namespace string, secretType string) (*corev1.SecretList, error)

GetSecretListByType get a list of secrets than select by type.

func (*GoClient) GetService

func (c *GoClient) GetService(namespace, name string) (*corev1.Service, error)

func (*GoClient) GetServiceAccount

func (c *GoClient) GetServiceAccount(name, namespace string) (*corev1.ServiceAccount, error)

Get serviceAccount

func (*GoClient) GetServiceList

func (c *GoClient) GetServiceList(namespace string) (*corev1.ServiceList, error)

GetServiceList get a list of services.

func (*GoClient) GetStorageClassList

func (c *GoClient) GetStorageClassList() (*storagev1.StorageClassList, error)

func (*GoClient) GetVirtualService

func (c *GoClient) GetVirtualService(namespace, name string) (*v1alpha3.VirtualService, error)

func (*GoClient) GetVirtualServiceList

func (c *GoClient) GetVirtualServiceList(namespace string) (*v1alpha3.VirtualServiceList, error)

GetVirtualServiceList get a list of virtualservices.

func (*GoClient) IfNocalhostNameSpaceExist

func (c *GoClient) IfNocalhostNameSpaceExist() (bool, error)

check if exist namespace

func (*GoClient) IsAdmin

func (c *GoClient) IsAdmin() (bool, error)

check if admin for kubeconfig use SelfSubjectAccessReview check https://kubernetes.io/zh/docs/reference/access-authn-authz/authorization/ kubectl auth can-i '*' '*'

func (*GoClient) IsNamespaceExist

func (c *GoClient) IsNamespaceExist(ns string) (bool, error)

IsNamespaceExist check if exist namespace

func (*GoClient) ListClusterRoleBindingByLabel

func (c *GoClient) ListClusterRoleBindingByLabel(label string) (*rbacv1.ClusterRoleBindingList, error)

func (*GoClient) ListJobs

func (c *GoClient) ListJobs(namespace string) (*batchv1.JobList, error)

func (*GoClient) ListPods

func (c *GoClient) ListPods(namespace string) (*corev1.PodList, error)

func (*GoClient) MatchedArtifactVersion

func (c *GoClient) MatchedArtifactVersion(artifact, tags string) string

Sprintf the specify artifact while image == "" or use the default image from param

func (*GoClient) RefreshServiceAccount

func (c *GoClient) RefreshServiceAccount(name, namespace string)

nocalhost-dep watch the service account, so make some change to refresh the cache

func (*GoClient) RemoveClusterRoleBinding

func (c *GoClient) RemoveClusterRoleBinding(name, toServiceAccount, toServiceAccountNs string) error

func (*GoClient) RemoveRoleBinding

func (c *GoClient) RemoveRoleBinding(name, namespace, toServiceAccount, toServiceAccountNs string) error

func (*GoClient) UpdateClusterRole

func (c *GoClient) UpdateClusterRole(name string, rbacRule []rbacv1.PolicyRule) error

func (*GoClient) UpdateClusterRoleBindingForNocalhostLabel

func (c *GoClient) UpdateClusterRoleBindingForNocalhostLabel(name string) error

func (*GoClient) UpdateConfigMap

func (c *GoClient) UpdateConfigMap(namespace string, configmap *corev1.ConfigMap) (*corev1.ConfigMap, error)

func (*GoClient) UpdateDeployment

func (c *GoClient) UpdateDeployment(namespace string, deployment *v1.Deployment) (*v1.Deployment, error)

func (*GoClient) UpdateRole

func (c *GoClient) UpdateRole(name, namespace string, rbacRule []rbacv1.PolicyRule) error

func (*GoClient) UpdateRoleBindingForNocalhostLabel

func (c *GoClient) UpdateRoleBindingForNocalhostLabel(name, namespace string) error

func (*GoClient) UpdateSecret

func (c *GoClient) UpdateSecret(namespace string, secret *corev1.Secret) (*corev1.Secret, error)

func (*GoClient) UpdateService

func (c *GoClient) UpdateService(namespace string, service *corev1.Service) (*corev1.Service, error)

func (*GoClient) UpdateVirtualService

func (c *GoClient) UpdateVirtualService(namespace string,
	vs *v1alpha3.VirtualService) (*v1alpha3.VirtualService, error)

func (*GoClient) WatchServiceAccount

func (c *GoClient) WatchServiceAccount(name, namespace string) (*corev1.ServiceAccount, error)

Watch serviceAccount Bug Fix in Tencent TKE servieAccount secret will not return immediately

type InitResult

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

Jump to

Keyboard shortcuts

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