- Table Of Contents
- Running OpenShift locally using CodeReady Containers
- Automated Steps for running and testing NRI-Kubernetes on OpenShift Local
- Manual Steps for running and testing NRI-Kubernetes on OpenShift Local
- Accessing and exposing the internal Openshift image registry
- Deploying e2e-resources on OpenShift
- Misc Tips
For running and testing locally with OpenShift 4.18 and above, OpenShift Local To push a local compiled image to OpenShift, you'll need to expose and push it to the internal registry
- run
./openshift/crc_setup.shtoinstall, setup, and start OpenShift Local - run
./openshift/run.shfor everything else
- see ./openshift/README.md for more details
- Table Of Contents
- Running OpenShift locally using CodeReady Containers
- Automated Steps for running and testing NRI-Kubernetes on OpenShift Local
- Manual Steps for running and testing NRI-Kubernetes on OpenShift Local
- Accessing and exposing the internal Openshift image registry
- Deploying e2e-resources on OpenShift
- Misc Tips
- Download Openshift Local Installer and the pull secret
- Run the Installer
- Setup openshift local with the recommended settings for running e2e-tests locally
- initial setup takes ~10 minutes and some settings can only be set after it’s been setup
crc setup
crc config set enable-cluster-monitoring true
crc start -p ./pull-secret.txt
crc stop
crc config set cpus 8
crc config set memory 32768
crc config set disk-size 90
- keep track of the username and pw that is created for you during setup
- start openshift local:
crc start -p ./pull-secret.txt
- Decide what you want your scenario tag to be
- this will be the name of the cluster on NR1
- The namespace will be “NR-${scenario_tag}”
- e.g scenario_tag=orange, namespace=nr-orange
kubectl create namespace nr-orange
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-newrelic-infrastructure
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-nrk8s-controlplane
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-kube-state-metrics
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-newrelic-logging
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-nri-kube-events
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-nri-metadata-injection-admission
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:<release_name>-nrk8s-controlplane
oc adm policy add-scc-to-user privileged system:serviceaccount:<namespace>:default
for e2e-tests, the scenario_tag is the release_name and the namespace is nr-${scenario_tag}
- To setup mTLS for ETCD in OpenShift. Follow these instruction.
- Create a
./e2e/e2e-values-openshift.ymlfile with the following values.- This is to set up mTLS for etcd in OpenShift.
- added a namespace for the ksm scraper to search in because OpenShift has it's own kube-state-metrics
provider: OPEN_SHIFT
ksm:
config:
timeout: 60s
retries: 3
selector: "app.kubernetes.io/name=kube-state-metrics"
scheme: "http"
namespace: "${namespace}"
controlPlane:
config:
etcd:
enabled: true
autodiscover:
- selector: "app=etcd,etcd=true,k8s-app=etcd"
namespace: openshift-etcd
matchNode: true
endpoints:
- url: https://localhost:2379
insecureSkipVerify: true
auth:
type: mTLS
mtls:
secretName: my-etcd-secret
secretNamespace: ${namespace}
- Run the following commands to execute e2e tests:
Include helm needed repositories.
helm repo add newrelic https://helm-charts.newrelic.com
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
Install e2e integration runner
go install github.com/newrelic/newrelic-integration-e2e-action@latest
Execute e2e test with the specific openshift files
export EXCEPTION_SOURCE_FILE="1_32-exceptions-openshift.yml"
export LICENSE_KEY=xxx
export API_KEY=xxx
export ACCOUNT_ID=xxx
LICENSE_KEY=${LICENSE_KEY} EXCEPTIONS_SOURCE_FILE=${EXCEPTION_FILE} go run github.com/newrelic/newrelic-integration-e2e-action@latest \
--commit_sha=test-string --retry_attempts=5 --retry_seconds=60 \
--account_id=${ACCOUNT_ID} --api_key=${API_KEY} --license_key=${LICENSE_KEY} \
--spec_path=./e2e/test-specs-openshift.yml --verbose_mode=true --agent_enabled="false" --region="Staging"
- note these have OpenShift specific exceptions and test-spec files
- see the /e2e/README.md for more specifics
The local CRC development flow depends on the Openshift image registry being exposed outside the cluster and being accessible to a valid Openshift user. To achieve this, perform the following steps.
- Follow these steps to add
the
registry-viewerandregistry-editorrole to thedeveloperuser. - Follow these steps to expose the registry outside the cluster using the default route.
The namespace we'll be using as an example is e2e-openshift-running
- Create a new service account to be assigned to the hpa and statefulset deployment pods
oc create serviceaccount nri-bundle-sa
- Add the
privilegedscc to your new user
oc adm policy add-scc-to-user privileged system:serviceaccounts:e2e-openshift-running:nri-bundle-sa
- Enable OpenShift in the
charts/internal/e2e-resources/values.yaml
openShift:
enabled: true
- Enable multiNode if using OpenShift platform
persistentVolume:
enabled: true
multiNode: true
- Must run in
demomode
helm upgrade --install e2e-resources --set demo.enabled=true charts/internal/e2e-resources -n e2e-openshift-running
- If at any point you need to login to the guest VM, use the following command:
ssh -i ~/.crc/machines/crc/id_rsa core@$(crc ip) - When you get to the
crc startcommand, if you encounter errors related to timeouts when attempting to check DNS resolution from within the guest VM, proceed to stop the VM (crc stop) and then restart it withcrc start -n 8.8.8.8. - Make sure to follow the steps for accessing the
occommand via theCLIincluding running thecrc oc-envcommand and using theoc login ...command to login to the cluster.