controllers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPathPrefix         = "/apis/v1alpha1/cloudshell"
	DefaultIngressName        = "cloudshell-ingress"
	DefaultVirtualServiceName = "cloudshell-virtualService"
	DefaultServicePort        = 7681
	// CloudshellControllerFinalizer is added to cloudshell to ensure Work as well as the
	// execution space (namespace) is deleted before itself is deleted.
	CloudshellControllerFinalizer = "cloudtty.io/cloudshell-controller"
)

Variables

This section is empty.

Functions

func GenerateKubeconfigInCluster added in v0.2.0

func GenerateKubeconfigInCluster() ([]byte, error)

GenerateKubeconfigByInCluster load serviceaccount info under "/var/run/secrets/kubernetes.io/serviceaccount" and generate kubeconfig str.

func IngressNamespacedName

func IngressNamespacedName(cloudshell *cloudshellv1alpha1.CloudShell) types.NamespacedName

IngressNamespacedName return a namespacedName accroding to ingressConfig.

func SetRouteRulePath

func SetRouteRulePath(cloudshell *cloudshellv1alpha1.CloudShell) string

SetRouteRulePath return access url according to cloudshell.

func VsNamespacedName

func VsNamespacedName(cloudshell *cloudshellv1alpha1.CloudShell) types.NamespacedName

VsNamespacedName return a namespacedName accroding to virtaulServiceConfig.

Types

type CloudShellReconciler

type CloudShellReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

CloudShellReconciler reconciles a CloudShell object

func (*CloudShellReconciler) CreateCloudShellJob

func (c *CloudShellReconciler) CreateCloudShellJob(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) error

CreateCloudShellJob clould create a job for cloudshell, the job will running a cloudtty server in the pod. the job template set default images registry "ghcr.io" and default command, no modification is supported currently, the configmap must be existed in the cluster.

func (*CloudShellReconciler) CreateCloudShellService

func (c *CloudShellReconciler) CreateCloudShellService(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) (*corev1.Service, error)

CreateCloudShellService Create service resource for cloudshell, the service type is either ClusterIP, NodePort, Ingress or virtualService. if the expose model is ingress or virtualService. it will create clusterIP type service.

func (*CloudShellReconciler) CreateIngressForCloudshell

func (c *CloudShellReconciler) CreateIngressForCloudshell(ctx context.Context, service *corev1.Service, cloudshell *cloudshellv1alpha1.CloudShell) error

CreateIngressForCloudshell create ingress for cloudshell, if there isn't an ingress controller server in the cluster, the ingress is still not working. before create ingress, there's must a service as the ingress backend service. all of services should be loaded in an ingress "cloudshell-ingress".

func (*CloudShellReconciler) CreateRouteRule

func (c *CloudShellReconciler) CreateRouteRule(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) error

CreateRouteRule create a service resource in the same namespace of cloudshell no matter what expose model. if the expose model is ingress or virtualService, it will create additional resources, e.g: ingress or virtualService. and the accressUrl will be update.

func (*CloudShellReconciler) CreateVitualServiceForCloudshell

func (c *CloudShellReconciler) CreateVitualServiceForCloudshell(ctx context.Context, service *corev1.Service, cloudshell *cloudshellv1alpha1.CloudShell) error

CreateVitualServiceForCloudshell create a virtualService resource in the cluster. if there is no istio server be deployed in the cluster. will not create the resource.

func (*CloudShellReconciler) GetJobForCloudshell

func (c *CloudShellReconciler) GetJobForCloudshell(ctx context.Context, namespace string, owner *cloudshellv1alpha1.CloudShell) (*batchv1.Job, error)

GetJobForCloudshell to find job of cloudshell according to labels "ownership".

func (*CloudShellReconciler) GetMasterNodeIP

func (c *CloudShellReconciler) GetMasterNodeIP(ctx context.Context) (string, error)

GetMasterNodeIP could find the one master node IP.

func (*CloudShellReconciler) GetServiceForCloudshell

func (c *CloudShellReconciler) GetServiceForCloudshell(ctx context.Context, namespace string, owner *cloudshellv1alpha1.CloudShell) (*corev1.Service, error)

GetServiceForCloudshell to find service of cloudshell according to labels "ownership".

func (*CloudShellReconciler) Reconcile

func (c *CloudShellReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the CloudShell object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.0/pkg/reconcile

func (*CloudShellReconciler) SetupWithManager

func (c *CloudShellReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*CloudShellReconciler) UpdateCloudshellStatus

func (c *CloudShellReconciler) UpdateCloudshellStatus(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell, phase string) error

UpdateCloudshellStatus update the clodushell status.

Jump to

Keyboard shortcuts

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