Skip to content
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

[Feature] Support environment variables for KubeRay operator chart #978

Merged
merged 2 commits into from
Mar 24, 2023

Conversation

kevin85421
Copy link
Member

@kevin85421 kevin85421 commented Mar 20, 2023

Why are these changes needed?

I realized that KubeRay operator chart does not support environment variables until #951 (comment).

Related issue number

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

Screen Shot 2023-03-20 at 4 25 17 PM

# Update values.yaml
env:
- name: EXAMPLE_ENV
  value: "1"

# Install KubeRay operator
helm install kuberay-operator .

# Check Pod 
kubectl get pods kuberay-operator-ffd776d86-xt248 -o jsonpath='{range .spec.containers[*].env[*]}{@.name}{"="}{@.value}{"\n"}{end}'
# EXAMPLE_ENV=1

# Check Deployment
kubectl get deployments.apps kuberay-operator -o jsonpath='{range .spec.template.spec.containers[*].env[*]}{@.name}{"="}{@.value}{"\n"}{end}'
# EXAMPLE_ENV=1

@kevin85421 kevin85421 marked this pull request as ready for review March 20, 2023 23:27
@kevin85421
Copy link
Member Author

cc @Yicheng-Lu-llll @jasoonn

@Yicheng-Lu-llll
Copy link
Contributor

Yicheng-Lu-llll commented Mar 23, 2023

LGTM!

I've also tested the changes as follows(to see if the env var can be truly accessed):

Step 1:
Update the kuberay/helm-chart/kuberay-operator/values.yaml file by adding the following lines:

env:
- name: test
  value: 'test-if-works'

Step 2:
log the environment variable when Reconciling

// in kuberay/ray-operator/controllers/ray/raycluster_controller.go
func (r *RayClusterReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
	var err error
	r.Log.Info("get env var", "test:", os.Getenv("test"))

Step 3:
Build a new kuberay image.

Step 4:
Install kuberay using the newly built image by running the following command:
helm install kuberay-operator --set image.repository=kuberay/operator --set image.tag=nightly .

Step 5:
Check the logs of the kuberay operator to confirm the environment variable can be accessed:
kubectl logs $(kubectl get pods -o=name | grep operator)

should see the following output:

root@ip-172-31-14-57:/home/ubuntu/tmp/kuberay# kubectl logs $(kubectl get pods -o=name | grep operator) | grep "get env var"
2023-03-23T04:00:29.487Z        INFO    controllers.RayCluster  get env var     {"test:": "test-if-works"}

Copy link
Contributor

@gvspraveen gvspraveen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Can you update PR description with testing instructions like Yicheng comment?

@kevin85421
Copy link
Member Author

LGTM.

Can you update PR description with testing instructions like Yicheng comment?

Done

@kevin85421 kevin85421 merged commit baccb09 into ray-project:master Mar 24, 2023
lowang-bh pushed a commit to lowang-bh/kuberay that referenced this pull request Sep 24, 2023
…ay-project#978)

Support environment variables for KubeRay operator chart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants