-
Notifications
You must be signed in to change notification settings - Fork 61
Implement support for Volume components #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
553294f
Move lifecycle functions to separate package
amisevsk f76d79b
Add library functions for converting Containers
amisevsk 21778b9
Add library function for provisioning 'common' PVC storage
amisevsk 01c5ca8
Add library package for accomodating current Che Theia requirements
amisevsk 6221ca7
Make devworkspace reconciler use new devfile 2.0 libraries
amisevsk c8e9579
Add flattened devfile samples for testing
amisevsk 680e04b
Improve volume handling in library to correctly manage mountSources
amisevsk cdec8d5
Update reconciler to use library to decide if storage is needed
amisevsk c5c0fd9
Add tests for storage and container libraries
amisevsk e2ed92e
Fix issue with duplicate containerPort due to webviews endpoint
amisevsk 6ed526e
Use flattened web-terminal devworkspace in e2e tests
amisevsk de51953
Don't add projects volumeMount if container mounts it manually
amisevsk 3d1c1f0
Fix issue where volumeMounts were being unnecessarily added
amisevsk ce39b26
Add function to populate env vars required by machine-exec
amisevsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Copyright (c) 2019-2020 Red Hat, Inc. | ||
// This program and the accompanying materials are made | ||
// available under the terms of the Eclipse Public License 2.0 | ||
// which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 | ||
// | ||
// Contributors: | ||
// Red Hat, Inc. - initial API and implementation | ||
// | ||
|
||
// Package constants contains constants related to the devfile API spec (e.g. reserved env vars) | ||
package constants | ||
|
||
const ( | ||
ProjectsRootEnvVar = "PROJECTS_ROOT" | ||
ProjectsSourceEnvVar = "PROJECTS_SOURCE" | ||
ProjectsVolumeName = "projects" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// Copyright (c) 2019-2020 Red Hat, Inc. | ||
// This program and the accompanying materials are made | ||
// available under the terms of the Eclipse Public License 2.0 | ||
// which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 | ||
// | ||
// Contributors: | ||
// Red Hat, Inc. - initial API and implementation | ||
// | ||
|
||
// Package container contains library functions for converting DevWorkspace Container components to Kubernetes | ||
// components | ||
// | ||
// TODO: | ||
// - Devfile API spec is unclear on how mountSources should be handled -- mountPath is assumed to be /projects | ||
// and volume name is assumed to be "projects" | ||
// see issues: | ||
// - https://github.com/devfile/api/issues/290 | ||
// - https://github.com/devfile/api/issues/291 | ||
package container | ||
|
||
import ( | ||
"fmt" | ||
|
||
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" | ||
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1" | ||
"github.com/devfile/devworkspace-operator/pkg/library" | ||
"github.com/devfile/devworkspace-operator/pkg/library/lifecycle" | ||
) | ||
|
||
// GetKubeContainersFromDevfile converts container components in a DevWorkspace into Kubernetes containers. | ||
// If a DevWorkspace container is an init container (i.e. is bound to a preStart event), it will be returned as an | ||
// init container. | ||
// | ||
// This function also provisions volume mounts on containers as follows: | ||
// - Container component's volume mounts are provisioned with the mount path and name specified in the devworkspace | ||
// However, no Volumes are added to the returned PodAdditions at this stage; the volumeMounts above are expected to be | ||
// rewritten as Volumes are added to PodAdditions, in order to support e.g. using one PVC to hold all volumes | ||
// | ||
// Note: Requires DevWorkspace to be flattened (i.e. the DevWorkspace contains no Parent or Components of type Plugin) | ||
func GetKubeContainersFromDevfile(workspace devworkspace.DevWorkspaceTemplateSpec) (*v1alpha1.PodAdditions, error) { | ||
if !library.DevWorkspaceIsFlattened(workspace) { | ||
return nil, fmt.Errorf("devfile is not flattened") | ||
} | ||
podAdditions := &v1alpha1.PodAdditions{} | ||
|
||
initContainers, mainComponents, err := lifecycle.GetInitContainers(workspace.DevWorkspaceTemplateSpecContent) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, component := range mainComponents { | ||
if component.Container == nil { | ||
continue | ||
} | ||
k8sContainer, err := convertContainerToK8s(component) | ||
if err != nil { | ||
return nil, err | ||
} | ||
handleMountSources(k8sContainer, component.Container) | ||
podAdditions.Containers = append(podAdditions.Containers, *k8sContainer) | ||
} | ||
|
||
for _, container := range initContainers { | ||
k8sContainer, err := convertContainerToK8s(container) | ||
if err != nil { | ||
return nil, err | ||
} | ||
handleMountSources(k8sContainer, container.Container) | ||
podAdditions.InitContainers = append(podAdditions.InitContainers, *k8sContainer) | ||
} | ||
|
||
return podAdditions, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.