Skip to content

Commit 32ce88a

Browse files
committed
Finalize workspace to DevWorkspace renaming
1 parent 661c656 commit 32ce88a

File tree

135 files changed

+7794
-5211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+7794
-5211
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export ROUTING_SUFFIX ?= 192.168.99.100.nip.io
2323
export PULL_POLICY ?= Always
2424
export DEFAULT_ROUTING ?= basic
2525
export KUBECONFIG ?= ${HOME}/.kube/config
26-
export DEVWORKSPACE_API_VERSION ?= 283b0c54946e9fea9872c25e1e086c303688f0e8
26+
#TODO Revert before merge
27+
export DEVWORKSPACE_API_VERSION ?= 546111ae6350d790ef1dcaa58aa7d78dce205e96
2728

2829
#internal params
2930
DEVWORKSPACE_CTRL_SA=devworkspace-controller-serviceaccount

PROJECT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
domain: devfile.io
22
layout: go.kubebuilder.io/v2
33
multigroup: true
4-
projectName: devworkspace-operator-migration
4+
projectName: devworkspace-operator
55
repo: github.com/devfile/devworkspace-operator
66
resources:
77
- group: controller

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You can add these Kubernetes annotations to specific DevWorkspace CR to customiz
1616

1717
The `controller.devfile.io/restricted-access` specifies that a DevWorkspace needs additional access control (in addition to RBAC). When a DevWorkspace is created with the `controller.devfile.io/restricted-access` annotation set to `true`, the webhook server will guarantee
1818
- Only the DevWorkspace Operator ServiceAccount or DevWorkspace creator can modify important fields in the devworksapce
19-
- Only the DevWorkspace creator can create `pods/exec` into workspace-related containers.
19+
- Only the DevWorkspace creator can create `pods/exec` into devworkspace-related containers.
2020

2121
This annotation should be used when a DevWorkspace is expected to contain sensitive information that should be protect above the protection provided by standard RBAC rules (e.g. if the DevWorkspace will store the user's OpenShift token in-memory).
2222

@@ -49,7 +49,7 @@ export DWO_IMG=quay.io/devfile/devworkspace-controller:next
4949
make install
5050
```
5151

52-
By default, controller will expose workspace servers without any authentication; this is not advisable for public clusters, as any user could access the created workspace via URL.
52+
By default, controller will expose devworkspace servers without any authentication; this is not advisable for public clusters, as any user could access the created devworkspace via URL.
5353

5454
In case of OpenShift, you're able to configure DevWorkspace CR to secure your servers with the following piece of configuration:
5555

@@ -95,9 +95,9 @@ Some of the rules supported by the makefile:
9595
To see all rules supported by the makefile, run `make help`
9696

9797
### Test run controller
98-
1. Take a look samples workspace configuration in `./samples` folder.
99-
2. Apply any of them by executing `kubectl apply -f ./samples/workspace_java_mysql.yaml -n <namespace>`
100-
3. As soon as workspace is started you're able to get IDE url by executing `kubectl get devworkspace -n <namespace>`
98+
1. Take a look samples devworkspace configuration in `./samples` folder.
99+
2. Apply any of them by executing `kubectl apply -f ./samples/flattened_theia-next.yaml -n <namespace>`
100+
3. As soon as devworkspace is started you're able to get IDE url by executing `kubectl get devworkspace -n <namespace>`
101101

102102
### Run controller locally
103103
```bash
@@ -106,7 +106,7 @@ oc patch deployment/devworkspace-controller-manager --patch "{\"spec\":{\"replic
106106
make run
107107
```
108108

109-
When running locally, only a single namespace is watched; as a result, all workspaces have to be deployed to `${NAMESPACE}`
109+
When running locally, only a single namespace is watched; as a result, all devworkspaces have to be deployed to `${NAMESPACE}`
110110

111111
### Run controller locally and debug
112112
Debugging the controller depends on `delve` being installed (`go get -u github.com/go-delve/delve/cmd/dlv`). Note that at the time of writing, executing `go get` in this repo's directory will update go.mod; these changes should be dropped before committing.

apis/controller/v1alpha1/common.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,44 @@ package v1alpha1
1414

1515
import v1 "k8s.io/api/core/v1"
1616

17-
// Summary of additions that are to be merged into the main workspace deployment
17+
// Summary of additions that are to be merged into the main devworkspace deployment
1818
type PodAdditions struct {
19-
// Annotations to be applied to workspace deployment
19+
// Annotations to be applied to devworkspace deployment
2020
// +optional
2121
// +patchMergeKey=name
2222
// +patchStrategy=merge
2323
Annotations map[string]string `json:"annotations,omitempty"`
24-
// Labels to be applied to workspace deployment
24+
// Labels to be applied to devworkspace deployment
2525
// +optional
2626
// +patchMergeKey=name
2727
// +patchStrategy=merge
2828
Labels map[string]string `json:"labels,omitempty"`
29-
// Containers to add to workspace deployment
29+
// Containers to add to devworkspace deployment
3030
// +optional
3131
// +patchMergeKey=name
3232
// +patchStrategy=merge
3333
Containers []v1.Container `json:"containers,omitempty"`
34-
// Init containers to add to workspace deployment
34+
// Init containers to add to devworkspace deployment
3535
// +optional
3636
// +patchMergeKey=name
3737
// +patchStrategy=merge
3838
InitContainers []v1.Container `json:"initContainers,omitempty"`
39-
// Volumes to add to workspace deployment
39+
// Volumes to add to devworkspace deployment
4040
// +optional
4141
// +patchMergeKey=name
4242
// +patchStrategy=merge
4343
Volumes []v1.Volume `json:"volumes,omitempty"`
44-
// VolumeMounts to add to all containers in a workspace deployment
44+
// VolumeMounts to add to all containers in a devworkspace deployment
4545
// +optional
4646
// +patchMergeKey=name
4747
// +patchStrategy=merge
4848
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
49-
// ImagePullSecrets to add to workspace deployment
49+
// ImagePullSecrets to add to devworkspace deployment
5050
// +optional
5151
// +patchMergeKey=name
5252
// +patchStrategy=merge
5353
PullSecrets []v1.LocalObjectReference `json:"pullSecrets,omitempty"`
54-
// Annotations for the workspace service account, it might be used for e.g. OpenShift oauth with SA as auth client
54+
// Annotations for the devworkspace service account, it might be used for e.g. OpenShift oauth with SA as auth client
5555
// +optional
5656
// +patchMergeKey=name
5757
// +patchStrategy=merge

apis/controller/v1alpha1/devworkspacerouting_types.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
package v1alpha1
1414

1515
import (
16-
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
16+
dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
1717
devfileAttr "github.com/devfile/api/v2/pkg/attributes"
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
)
2020

2121
// DevWorkspaceRoutingSpec defines the desired state of DevWorkspaceRouting
2222
// +k8s:openapi-gen=true
2323
type DevWorkspaceRoutingSpec struct {
24-
// WorkspaceId for the workspace being routed
25-
WorkspaceId string `json:"workspaceId"`
26-
// Class of the routing: this drives which Workspace Routing controller will manage this routing
24+
// Id for the DevWorkspace being routed
25+
DevWorkspaceId string `json:"devWorkspaceId"`
26+
// Class of the routing: this drives which DevWorkspaceRouting controller will manage this routing
2727
RoutingClass DevWorkspaceRoutingClass `json:"routingClass,omitempty"`
2828
// Routing suffix for cluster
2929
RoutingSuffix string `json:"routingSuffix"`
3030
// Machines to endpoints map
3131
Endpoints map[string]EndpointList `json:"endpoints"`
32-
// Selector that should be used by created services to point to the workspace Pod
32+
// Selector that should be used by created services to point to the devworkspace Pod
3333
PodSelector map[string]string `json:"podSelector"`
3434
}
3535

@@ -46,7 +46,7 @@ const (
4646
// DevWorkspaceRoutingStatus defines the observed state of DevWorkspaceRouting
4747
// +k8s:openapi-gen=true
4848
type DevWorkspaceRoutingStatus struct {
49-
// Additions to main workspace deployment
49+
// Additions to main devworkspace deployment
5050
PodAdditions *PodAdditions `json:"podAdditions,omitempty"`
5151
// Machine name to exposed endpoint map
5252
ExposedEndpoints map[string]ExposedEndpointList `json:"exposedEndpoints,omitempty"`
@@ -73,7 +73,7 @@ type ExposedEndpoint struct {
7373
Attributes devfileAttr.Attributes `json:"attributes,omitempty"`
7474
}
7575

76-
type EndpointList []devworkspace.Endpoint
76+
type EndpointList []dw.Endpoint
7777

7878
type ExposedEndpointList []ExposedEndpoint
7979

apis/controller/v1alpha1/zz_generated.deepcopy.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/controller/devworkspacerouting/devworkspacerouting_controller.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
7878
// Error reading the object - requeue the request.
7979
return reconcile.Result{}, err
8080
}
81-
reqLogger = reqLogger.WithValues(constants.WorkspaceIDLoggerKey, instance.Spec.WorkspaceId)
81+
reqLogger = reqLogger.WithValues(constants.DevWorkspaceIDLoggerKey, instance.Spec.DevWorkspaceId)
8282
reqLogger.Info("Reconciling DevWorkspaceRouting")
8383

8484
if instance.Spec.RoutingClass == "" {
85-
reqLogger.Info("workspace routing without an explicit routing class is invalid", "name", instance.Name, "namespace", instance.Namespace)
85+
reqLogger.Info("DevWorkspaceRouting without an explicit routing class is invalid", "name", instance.Name, "namespace", instance.Namespace)
8686
return reconcile.Result{}, r.markRoutingFailed(instance)
8787
}
8888

@@ -91,7 +91,7 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
9191
if errors.Is(err, solvers.RoutingNotSupported) {
9292
return reconcile.Result{}, nil
9393
}
94-
reqLogger.Error(err, "Invalid routing class for workspace")
94+
reqLogger.Error(err, "Invalid routing class for DevWorkspace")
9595
return reconcile.Result{}, r.markRoutingFailed(instance)
9696
}
9797

@@ -111,14 +111,14 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
111111
return reconcile.Result{}, err
112112
}
113113

114-
workspaceMeta := solvers.WorkspaceMetadata{
115-
WorkspaceId: instance.Spec.WorkspaceId,
116-
Namespace: instance.Namespace,
117-
PodSelector: instance.Spec.PodSelector,
118-
RoutingSuffix: instance.Spec.RoutingSuffix,
114+
workspaceMeta := solvers.DevWorkspaceMetadata{
115+
DevWorkspaceId: instance.Spec.DevWorkspaceId,
116+
Namespace: instance.Namespace,
117+
PodSelector: instance.Spec.PodSelector,
118+
RoutingSuffix: instance.Spec.RoutingSuffix,
119119
}
120120

121-
restrictedAccess, setRestrictedAccess := instance.Annotations[constants.WorkspaceRestrictedAccessAnnotation]
121+
restrictedAccess, setRestrictedAccess := instance.Annotations[constants.DevWorkspaceRestrictedAccessAnnotation]
122122
routingObjects, err := solver.GetSpecObjects(instance, workspaceMeta)
123123
if err != nil {
124124
var notReady *solvers.RoutingNotReady
@@ -127,7 +127,7 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
127127
if duration.Milliseconds() == 0 {
128128
duration = 1 * time.Second
129129
}
130-
reqLogger.Info("controller not ready for workspace routing. Retrying", "DelayMs", duration.Milliseconds())
130+
reqLogger.Info("controller not ready for devworkspace routing. Retrying", "DelayMs", duration.Milliseconds())
131131
return reconcile.Result{RequeueAfter: duration}, nil
132132
}
133133

@@ -148,7 +148,7 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
148148
return reconcile.Result{}, err
149149
}
150150
if setRestrictedAccess {
151-
services[idx].Annotations = maputils.Append(services[idx].Annotations, constants.WorkspaceRestrictedAccessAnnotation, restrictedAccess)
151+
services[idx].Annotations = maputils.Append(services[idx].Annotations, constants.DevWorkspaceRestrictedAccessAnnotation, restrictedAccess)
152152
}
153153
}
154154
ingresses := routingObjects.Ingresses
@@ -158,7 +158,7 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
158158
return reconcile.Result{}, err
159159
}
160160
if setRestrictedAccess {
161-
ingresses[idx].Annotations = maputils.Append(ingresses[idx].Annotations, constants.WorkspaceRestrictedAccessAnnotation, restrictedAccess)
161+
ingresses[idx].Annotations = maputils.Append(ingresses[idx].Annotations, constants.DevWorkspaceRestrictedAccessAnnotation, restrictedAccess)
162162
}
163163
}
164164
routes := routingObjects.Routes
@@ -168,7 +168,7 @@ func (r *DevWorkspaceRoutingReconciler) Reconcile(req ctrl.Request) (ctrl.Result
168168
return reconcile.Result{}, err
169169
}
170170
if setRestrictedAccess {
171-
routes[idx].Annotations = maputils.Append(routes[idx].Annotations, constants.WorkspaceRestrictedAccessAnnotation, restrictedAccess)
171+
routes[idx].Annotations = maputils.Append(routes[idx].Annotations, constants.DevWorkspaceRestrictedAccessAnnotation, restrictedAccess)
172172
}
173173
}
174174

controllers/controller/devworkspacerouting/solvers/basic_solver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
var routeAnnotations = func(endpointName string) map[string]string {
2222
return map[string]string{
2323
"haproxy.router.openshift.io/rewrite-target": "/",
24-
constants.WorkspaceEndpointNameAnnotation: endpointName,
24+
constants.DevWorkspaceEndpointNameAnnotation: endpointName,
2525
}
2626
}
2727

@@ -30,7 +30,7 @@ var nginxIngressAnnotations = func(endpointName string) map[string]string {
3030
"kubernetes.io/ingress.class": "nginx",
3131
"nginx.ingress.kubernetes.io/rewrite-target": "/",
3232
"nginx.ingress.kubernetes.io/ssl-redirect": "false",
33-
constants.WorkspaceEndpointNameAnnotation: endpointName,
33+
constants.DevWorkspaceEndpointNameAnnotation: endpointName,
3434
}
3535
}
3636

@@ -50,7 +50,7 @@ func (s *BasicSolver) Finalize(*controllerv1alpha1.DevWorkspaceRouting) error {
5050
return nil
5151
}
5252

53-
func (s *BasicSolver) GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta WorkspaceMetadata) (RoutingObjects, error) {
53+
func (s *BasicSolver) GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta DevWorkspaceMetadata) (RoutingObjects, error) {
5454
routingObjects := RoutingObjects{}
5555

5656
spec := routing.Spec

controllers/controller/devworkspacerouting/solvers/cluster_solver.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/devfile/devworkspace-operator/pkg/common"
1919
"github.com/devfile/devworkspace-operator/pkg/constants"
2020

21-
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
21+
dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
2222
corev1 "k8s.io/api/core/v1"
2323

2424
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
@@ -42,7 +42,7 @@ func (s *ClusterSolver) Finalize(*controllerv1alpha1.DevWorkspaceRouting) error
4242
return nil
4343
}
4444

45-
func (s *ClusterSolver) GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta WorkspaceMetadata) (RoutingObjects, error) {
45+
func (s *ClusterSolver) GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta DevWorkspaceMetadata) (RoutingObjects, error) {
4646
spec := routing.Spec
4747
services := getServicesForEndpoints(spec.Endpoints, workspaceMeta)
4848
podAdditions := &controllerv1alpha1.PodAdditions{}
@@ -84,7 +84,7 @@ func (s *ClusterSolver) GetExposedEndpoints(
8484

8585
for machineName, machineEndpoints := range endpoints {
8686
for _, endpoint := range machineEndpoints {
87-
if endpoint.Exposure == devworkspace.NoneEndpointExposure {
87+
if endpoint.Exposure == dw.NoneEndpointExposure {
8888
continue
8989
}
9090
url, err := resolveServiceHostnameForEndpoint(endpoint, routingObj.Services)
@@ -103,9 +103,9 @@ func (s *ClusterSolver) GetExposedEndpoints(
103103
return exposedEndpoints, true, nil
104104
}
105105

106-
func resolveServiceHostnameForEndpoint(endpoint devworkspace.Endpoint, services []corev1.Service) (string, error) {
106+
func resolveServiceHostnameForEndpoint(endpoint dw.Endpoint, services []corev1.Service) (string, error) {
107107
for _, service := range services {
108-
if service.Annotations[constants.WorkspaceDiscoverableServiceAnnotation] == "true" {
108+
if service.Annotations[constants.DevWorkspaceDiscoverableServiceAnnotation] == "true" {
109109
continue
110110
}
111111
for _, servicePort := range service.Spec.Ports {

0 commit comments

Comments
 (0)