|
1 | 1 | package v1alpha1 |
2 | 2 |
|
3 | | -import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | +) |
| 7 | + |
| 8 | +const ( |
| 9 | + // WorkspaceProxyPhasePending indicates the proxy deployment is not ready. |
| 10 | + WorkspaceProxyPhasePending = "Pending" |
| 11 | + // WorkspaceProxyPhaseReady indicates at least one proxy pod is ready. |
| 12 | + WorkspaceProxyPhaseReady = "Ready" |
| 13 | +) |
| 14 | + |
| 15 | +// ProxyBootstrapSpec configures optional registration with the Coder API. |
| 16 | +type ProxyBootstrapSpec struct { |
| 17 | + // CoderURL is the URL for the primary Coder control plane API. |
| 18 | + CoderURL string `json:"coderURL"` |
| 19 | + // CredentialsSecretRef points to a Secret containing a Coder session token. |
| 20 | + CredentialsSecretRef SecretKeySelector `json:"credentialsSecretRef"` |
| 21 | + // ProxyName is the name used when registering the proxy in Coder. |
| 22 | + ProxyName string `json:"proxyName,omitempty"` |
| 23 | + // DisplayName is the human-readable name for the proxy region. |
| 24 | + DisplayName string `json:"displayName,omitempty"` |
| 25 | + // Icon is the optional icon URL or emoji path for the proxy region. |
| 26 | + Icon string `json:"icon,omitempty"` |
| 27 | + // GeneratedTokenSecretName stores the generated proxy token. |
| 28 | + GeneratedTokenSecretName string `json:"generatedTokenSecretName,omitempty"` |
| 29 | +} |
| 30 | + |
| 31 | +// WorkspaceProxySpec defines the desired state of a WorkspaceProxy. |
| 32 | +type WorkspaceProxySpec struct { |
| 33 | + // Image is the container image used for the workspace proxy pod. |
| 34 | + Image string `json:"image,omitempty"` |
| 35 | + // Replicas is the desired number of proxy pods. |
| 36 | + Replicas *int32 `json:"replicas,omitempty"` |
| 37 | + // Service controls the service created in front of the workspace proxy. |
| 38 | + // +kubebuilder:default={} |
| 39 | + Service ServiceSpec `json:"service,omitempty"` |
| 40 | + // PrimaryAccessURL is the coderd URL the proxy should connect to. |
| 41 | + PrimaryAccessURL string `json:"primaryAccessURL,omitempty"` |
| 42 | + // ProxySessionTokenSecretRef points to a Secret key containing the proxy token. |
| 43 | + ProxySessionTokenSecretRef *SecretKeySelector `json:"proxySessionTokenSecretRef,omitempty"` |
| 44 | + // Bootstrap optionally registers the proxy and mints a proxy token. |
| 45 | + Bootstrap *ProxyBootstrapSpec `json:"bootstrap,omitempty"` |
| 46 | + // DerpOnly configures the workspace proxy to only serve DERP traffic. |
| 47 | + DerpOnly bool `json:"derpOnly,omitempty"` |
| 48 | + // ExtraArgs are appended to the default workspace proxy arguments. |
| 49 | + ExtraArgs []string `json:"extraArgs,omitempty"` |
| 50 | + // ExtraEnv are injected into the workspace proxy container. |
| 51 | + ExtraEnv []corev1.EnvVar `json:"extraEnv,omitempty"` |
| 52 | + // ImagePullSecrets are used by the pod to pull private images. |
| 53 | + ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` |
| 54 | +} |
| 55 | + |
| 56 | +// WorkspaceProxyStatus defines the observed state of a WorkspaceProxy. |
| 57 | +type WorkspaceProxyStatus struct { |
| 58 | + // ObservedGeneration tracks the spec generation this status reflects. |
| 59 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 60 | + // ReadyReplicas is the number of ready pods observed in the deployment. |
| 61 | + ReadyReplicas int32 `json:"readyReplicas,omitempty"` |
| 62 | + // Registered reports whether bootstrap registration completed successfully. |
| 63 | + Registered bool `json:"registered,omitempty"` |
| 64 | + // ProxyTokenSecretRef is the Secret used for the proxy session token. |
| 65 | + ProxyTokenSecretRef *SecretKeySelector `json:"proxyTokenSecretRef,omitempty"` |
| 66 | + // Phase is a high-level readiness indicator. |
| 67 | + Phase string `json:"phase,omitempty"` |
| 68 | + // Conditions are Kubernetes-standard conditions for this resource. |
| 69 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 70 | +} |
4 | 71 |
|
5 | 72 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
6 | 73 | // +kubebuilder:object:root=true |
|
0 commit comments