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

Add Helm Operator for OpenJ9 JITServer #81

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions helm-operator/openj9-jitserver-operator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# JITServer Operator

## Installation and deployment

### Requirements
- `kubectl` installed
- A running kubernetes cluster

### Installation
You can install the JITServer Operator into a Kubernetes cluster via `kubectl` commands.

- Deploy the operator:

```
kubectl apply -f https://raw.githubusercontent.com/eclipse-openj9/openj9-utils/master/helm-operator/openj9-jitserver-operator/deploy.yaml
```

- Verify the operator is running:

```
kubectl get deployment -n jitserver-operator-system | grep jitserver-operator

jitserver-operator-controller-manager 1/1 1 1 11s
```

```
kubectl get pods -n jitserver-operator-system | grep jitserver-operator

jitserver-operator-controller-manager-7dc5df6d68-g62kr 2/2 Running 0 48s
```

- Deploy the Custom Resource:

```
kubectl apply -f https://raw.githubusercontent.com/eclipse-openj9/openj9-utils/master/helm-operator/openj9-jitserver-operator/charts_v1alpha1_openj9jitserverchart.yaml
```

- Verify the Custom Resource is running:

```
kubectl get deployment | grep openj9jitserverchart

openj9jitserverchart-sample-openj9-jitserver-chart 1/1 1 1 13s
```

```
kubectl get pods | grep openj9jitserverchart

openj9jitserverchart-sample-openj9-jitserver-chart-5d5696fcz626 1/1 Running 0 54s
```

- Issue a sample query to the Custom Resource:

```
export POD_NAME=$(kubectl get pod --namespace default -o jsonpath="{..metadata.name}" | grep openj9jitserverchart-sample-openj9-jitserver-chart)
kubectl exec $POD_NAME -i -t -- java -version

openjdk version "1.8.0_322"
IBM Semeru Runtime Open Edition (build 1.8.0_322-b06)
Eclipse OpenJ9 VM (build openj9-0.30.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220128_306 (JIT enabled, AOT enabled)
OpenJ9 - 9dccbe076
OMR - dac962a28
JCL - c1d9a7af7c based on jdk8u322-b06)
```

- Deploy JITServer with a specific Java version:

To change the Java version for JITServer, you need to first download the JITServer Custom Resource YAML file.
```
curl -O https://raw.githubusercontent.com/eclipse-openj9/openj9-utils/master/helm-operator/openj9-jitserver-operator/charts_v1alpha1_openj9jitserverchart.yaml
```

Now, change `spec.image.tag` in `charts_v1alpha1_openj9jitserverchart.yaml` to the appropriate Java version docker image tag.

Then deploy the JITServer Custom Resource.
```
kubectl apply -f charts_v1alpha1_openj9jitserverchart.yaml
```

- Deploy two different JITServer deployments:

Download the JITServer Custom Resource YAML file.
```
curl -O https://raw.githubusercontent.com/eclipse-openj9/openj9-utils/master/helm-operator/openj9-jitserver-operator/charts_v1alpha1_openj9jitserverchart.yaml
```

Create a copy of the JITServer Custom Resource YAML file with a different name.
```
cp charts_v1alpha1_openj9jitserverchart.yaml charts_v1alpha1_openj9jitserverchart_1.yaml
```

Now, change `spec.image.tag` in `charts_v1alpha1_openj9jitserverchart.yaml` and `charts_v1alpha1_openj9jitserverchart_1.yaml` to the appropriate Java version docker image tag.

Then deploy the JITServer Custom Resources.
```
kubectl apply -f charts_v1alpha1_openj9jitserverchart.yaml charts_v1alpha1_openj9jitserverchart_1.yaml
```

### Uninstallation
- Clean up the Custom Resource:
```
kubectl delete -f charts_v1alpha1_openj9jitserverchart.yaml
```

- Delete the operator:
```
kubectl delete -f deploy.yaml
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###############################################################################
# Copyright (c) 2020, 2022 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] http://openjdk.java.net/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
###############################################################################

apiVersion: charts.openj9jitserver/v1alpha1
kind: Openj9JitserverChart
metadata:
name: openj9jitserverchart-sample
spec:
# Default values copied from <project_dir>/helm-charts/openj9-jitserver-chart/values.yaml
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: beta.kubernetes.io/arch
operator: In
values:
- amd64
- ppc64le
- s390x
env:
- name: OPENJ9_JAVA_OPTIONS
value: ""
fullnameOverride: ""
image:
pullPolicy: IfNotPresent
repository: ibm-semeru-runtimes
tag: open-8u322-b06-jre
imagePullSecrets: []
nameOverride: ""
nodeSelector: {}
podSecurityContext: {}
replicaCount: 1
resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 1
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
service:
port: 38400
sessionAffinity: ClientIP
type: ClusterIP
serviceAccount:
annotations: {}
create: true
name: null
tolerations: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Create your own JITServer Operator

### Requirements
- `operator-sdk`
- `kubectl`
- `helm`
- A running kubernetes cluster

### Steps

- Add OpenJ9 JITServer helm chart repository to the Helm client:

```
helm repo add openj9 https://raw.githubusercontent.com/eclipse/openj9-utils/master/helm-chart/
helm repo update
helm search repo openj9-jitserver-chart
```

- Use the CLI to create a new Helm-based jitserver-operator project:

```
mkdir jitserver-operator
cd jitserver-operator
operator-sdk init --plugins helm --helm-chart openj9/openj9-jitserver-chart --domain openj9jitserver
```

- Build and push your operator’s image:

```
make docker-build docker-push IMG="<your-docker-hub-user-namespace>/jitserver-operator:v0.0.1"
```

- Run the operator as a Deployment inside the cluster:

```
make deploy IMG="<your-docker-hub-user-namespace>/jitserver-operator:v0.0.1"
```

- Verify the operator is running:

```
kubectl get deployment -n jitserver-operator-system | grep jitserver-operator

jitserver-operator-controller-manager 1/1 1 1 11s
```

```
kubectl get pods -n jitserver-operator-system | grep jitserver-operator

jitserver-operator-controller-manager-7dc5df6d68-g62kr 2/2 Running 0 48s
```

- Update the sample JITServer Custom Resource manifest at `config/samples/charts_v1alpha1_openj9jitserverchart.yaml` to set your desired values.

- Create a JITServer Custom Resource:

```
kubectl apply -f config/samples/charts_v1alpha1_openj9jitserverchart.yaml
```

- Ensure that the JITServer operator creates the deployment for the Custom Resource:

```
kubectl get deployment | grep openj9jitserverchart

openj9jitserverchart-sample-openj9-jitserver-chart 1/1 1 1 13s
```

```
kubectl get pods | grep openj9jitserverchart

openj9jitserverchart-sample-openj9-jitserver-chart-5d5696fcz626 1/1 Running 0 54s
```

- Issue a sample query to the Custom Resource:

```
export POD_NAME=$(kubectl get pod --namespace default -o jsonpath="{..metadata.name}" | grep openj9jitserverchart-sample-openj9-jitserver-chart)
kubectl exec $POD_NAME -i -t -- java -version

openjdk version "1.8.0_322"
IBM Semeru Runtime Open Edition (build 1.8.0_322-b06)
Eclipse OpenJ9 VM (build openj9-0.30.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220128_306 (JIT enabled, AOT enabled)
OpenJ9 - 9dccbe076
OMR - dac962a28
JCL - c1d9a7af7c based on jdk8u322-b06)
```

Loading