From d07f72baa4face6ae9c530fbbe17182225748c7c Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Fri, 4 Dec 2020 10:12:04 -0600 Subject: [PATCH 1/8] Upgrade quarkus from 1.2.1.Final to the latest 1.9.0.Final in order to include kubernetes-client of at least 4.11.x (4.12.x is included in 1.9.0.Final). This is necessary for us to be able to leverage the v1 API for CustomResourceDefinition as v1beta1 is deprecated and will soon be removed. --- olm/operator-resources/instana-agent-operator.yaml | 7 ++++--- pom.xml | 2 +- src/main/java/com/instana/operator/AgentDeployer.java | 2 +- .../java/com/instana/operator/CustomResourceWatcher.java | 6 ++---- src/main/java/com/instana/operator/cache/Cache.java | 2 +- .../java/com/instana/operator/cache/ListerWatcher.java | 4 ++-- .../instana/operator/client/KubernetesClientProducer.java | 3 +-- src/test/java/com/instana/operator/AgentDeployerTest.java | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/olm/operator-resources/instana-agent-operator.yaml b/olm/operator-resources/instana-agent-operator.yaml index ebbf20dc..57a083b3 100644 --- a/olm/operator-resources/instana-agent-operator.yaml +++ b/olm/operator-resources/instana-agent-operator.yaml @@ -67,9 +67,9 @@ rules: - 'events' verbs: - 'create' -# ------------------------------------------------------------------------- -# For the custom resource, the operator needs list, watch, get, update. -# ------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# For the custom resource, the operator needs list, watch, get, update, create. +# ----------------------------------------------------------------------------- - apiGroups: - 'instana.io' resources: @@ -79,6 +79,7 @@ rules: - 'update' - 'list' - 'watch' + - 'create' # ------------------------------------------------------------------------- # Below are the permissions are for the agent. # The operator needs these permissions to create the agent's cluster role. diff --git a/pom.xml b/pom.xml index 4a624211..0f42d58c 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ UTF-8 2.22.0 - 1.2.1.Final + 1.9.0.Final 1.62 1.8 UTF-8 diff --git a/src/main/java/com/instana/operator/AgentDeployer.java b/src/main/java/com/instana/operator/AgentDeployer.java index 8bce7430..adfe910a 100644 --- a/src/main/java/com/instana/operator/AgentDeployer.java +++ b/src/main/java/com/instana/operator/AgentDeployer.java @@ -30,7 +30,7 @@ import io.fabric8.kubernetes.api.model.VolumeBuilder; import io.fabric8.kubernetes.api.model.VolumeMount; import io.fabric8.kubernetes.api.model.VolumeMountBuilder; -import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition; +import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; import io.fabric8.kubernetes.api.model.apps.DaemonSet; import io.fabric8.kubernetes.api.model.apps.DaemonSetList; import io.fabric8.kubernetes.api.model.apps.DoneableDaemonSet; diff --git a/src/main/java/com/instana/operator/CustomResourceWatcher.java b/src/main/java/com/instana/operator/CustomResourceWatcher.java index 2babe88d..32f0c079 100644 --- a/src/main/java/com/instana/operator/CustomResourceWatcher.java +++ b/src/main/java/com/instana/operator/CustomResourceWatcher.java @@ -6,14 +6,12 @@ import com.instana.operator.customresource.DoneableInstanaAgent; import com.instana.operator.customresource.InstanaAgent; import com.instana.operator.customresource.InstanaAgentList; -import com.instana.operator.env.NamespaceProducer; import com.instana.operator.events.CustomResourceAdded; import com.instana.operator.events.CustomResourceDeleted; import com.instana.operator.events.CustomResourceModified; import com.instana.operator.events.CustomResourceOtherInstanceAdded; import com.instana.operator.events.OperatorLeaderElected; import io.fabric8.kubernetes.client.Watch; -import io.fabric8.kubernetes.client.Watcher; import io.fabric8.kubernetes.client.dsl.FilterWatchListMultiDeletable; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; @@ -61,7 +59,7 @@ public class CustomResourceWatcher { private final AtomicReference current = new AtomicReference<>(); public void onElectedLeader(@ObservesAsync OperatorLeaderElected _ev) { - List>> ops = new ArrayList<>(); + List> ops = new ArrayList<>(); if (targetNamespaces.isEmpty()) { LOGGER.info("Watching for " + KubernetesClientProducer.CRD_NAME + " resources in any namespace."); ops.add(client.inAnyNamespace()); @@ -72,7 +70,7 @@ public void onElectedLeader(@ObservesAsync OperatorLeaderElected _ev) { } } Cache cache = cacheService.newCache(InstanaAgent.class, InstanaAgentList.class); - for (FilterWatchListMultiDeletable> op : ops) { + for (FilterWatchListMultiDeletable op : ops) { cache.listThenWatch(op).subscribe(event -> handleCacheEvent(cache.get(event.getUid()))); } } diff --git a/src/main/java/com/instana/operator/cache/Cache.java b/src/main/java/com/instana/operator/cache/Cache.java index 6d7e9e38..9c9f9c02 100644 --- a/src/main/java/com/instana/operator/cache/Cache.java +++ b/src/main/java/com/instana/operator/cache/Cache.java @@ -35,7 +35,7 @@ public Optional get(String uid) { return map.get(uid); } - public Observable listThenWatch(FilterWatchListDeletable> op) { + public Observable listThenWatch(FilterWatchListDeletable op) { return listThenWatch(new ListerWatcher<>(op)); } diff --git a/src/main/java/com/instana/operator/cache/ListerWatcher.java b/src/main/java/com/instana/operator/cache/ListerWatcher.java index 74c03caa..9dae00d0 100644 --- a/src/main/java/com/instana/operator/cache/ListerWatcher.java +++ b/src/main/java/com/instana/operator/cache/ListerWatcher.java @@ -11,9 +11,9 @@ */ public class ListerWatcher> { - private final FilterWatchListDeletable> op; + private final FilterWatchListDeletable op; - ListerWatcher(FilterWatchListDeletable> op) { + ListerWatcher(FilterWatchListDeletable op) { this.op = op; } diff --git a/src/main/java/com/instana/operator/client/KubernetesClientProducer.java b/src/main/java/com/instana/operator/client/KubernetesClientProducer.java index d0eab269..f4183f56 100644 --- a/src/main/java/com/instana/operator/client/KubernetesClientProducer.java +++ b/src/main/java/com/instana/operator/client/KubernetesClientProducer.java @@ -4,7 +4,7 @@ import com.instana.operator.customresource.DoneableInstanaAgent; import com.instana.operator.customresource.InstanaAgent; import com.instana.operator.customresource.InstanaAgentList; -import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition; +import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.dsl.MixedOperation; @@ -34,7 +34,6 @@ import javax.net.ssl.X509TrustManager; import java.net.Proxy; import java.util.Arrays; -import java.util.Optional; import java.util.concurrent.TimeUnit; import static com.instana.operator.env.Environment.OPERATOR_NAMESPACE; diff --git a/src/test/java/com/instana/operator/AgentDeployerTest.java b/src/test/java/com/instana/operator/AgentDeployerTest.java index b1fff0ec..d3a0a781 100644 --- a/src/test/java/com/instana/operator/AgentDeployerTest.java +++ b/src/test/java/com/instana/operator/AgentDeployerTest.java @@ -25,7 +25,7 @@ import io.fabric8.kubernetes.api.model.Container; import io.fabric8.kubernetes.api.model.EnvVar; -import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionBuilder; +import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder; import io.fabric8.kubernetes.api.model.apps.DaemonSet; import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; From 693533e431ce0ba50830ae72d8185ad5ea7f048e Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Mon, 7 Dec 2020 12:53:43 -0600 Subject: [PATCH 2/8] Add additional error messaging if we fail to update the CustomResource status due to a lack of permissions --- .../com/instana/operator/AgentDeployer.java | 3 +- .../instana/operator/CustomResourceState.java | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/instana/operator/AgentDeployer.java b/src/main/java/com/instana/operator/AgentDeployer.java index adfe910a..d67d7221 100644 --- a/src/main/java/com/instana/operator/AgentDeployer.java +++ b/src/main/java/com/instana/operator/AgentDeployer.java @@ -70,6 +70,7 @@ import static com.instana.operator.util.StringUtils.isBlank; import static io.fabric8.kubernetes.client.Watcher.Action.ADDED; import static io.fabric8.kubernetes.client.Watcher.Action.DELETED; +import static java.net.HttpURLConnection.HTTP_CONFLICT; @ApplicationScoped public class AgentDeployer { @@ -204,7 +205,7 @@ void createResource(int nRetries, MixedOperation op, Factory 1) { + if (e.getCode() == HTTP_CONFLICT && nRetries > 1) { // Another resource of the same name exists in the same namespace. // Maybe it's currently being removed, try again in a few seconds. executor.schedule(() -> createResource(nRetries - 1, op, factory), 10, TimeUnit.SECONDS); diff --git a/src/main/java/com/instana/operator/CustomResourceState.java b/src/main/java/com/instana/operator/CustomResourceState.java index db542785..b24869c7 100644 --- a/src/main/java/com/instana/operator/CustomResourceState.java +++ b/src/main/java/com/instana/operator/CustomResourceState.java @@ -1,23 +1,28 @@ package com.instana.operator; +import static com.instana.operator.client.KubernetesClientProducer.CRD_NAME; +import static com.instana.operator.util.ResourceUtils.name; +import static java.net.HttpURLConnection.HTTP_FORBIDDEN; + +import java.util.Optional; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.instana.operator.customresource.DoneableInstanaAgent; import com.instana.operator.customresource.InstanaAgent; import com.instana.operator.customresource.InstanaAgentList; import com.instana.operator.customresource.InstanaAgentStatus; import com.instana.operator.customresource.ResourceInfo; + import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import java.util.Optional; - -import static com.instana.operator.client.KubernetesClientProducer.CRD_NAME; -import static com.instana.operator.util.ResourceUtils.name; @ApplicationScoped public class CustomResourceState { @@ -127,7 +132,14 @@ private void update() { try { client.inNamespace(customResource.getMetadata().getNamespace()).createOrReplace(customResource); } catch (Exception e) { - LOGGER.warn("Failed to update " + CRD_NAME + " " + name(customResource) + ": " + e.getMessage()); + StringBuilder errorMessage = new StringBuilder(); + errorMessage.append("Failed to update Custom Resource").append(CRD_NAME).append(name(customResource)); + if (e instanceof KubernetesClientException) { + if (((KubernetesClientException)e).getCode() == HTTP_FORBIDDEN) { + errorMessage.append(". Please ensure the operator has the updated cluster role permissions."); + } + } + LOGGER.warn(errorMessage.toString() + ": " + e.getMessage()); // No need to System.exit() if we cannot update the status. Ignore this and carry on. } } From e406181c9a21b8b4ecfc7d9ab5941be329f7c6d4 Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Fri, 4 Dec 2020 10:22:22 -0600 Subject: [PATCH 3/8] Update the local testing with Kind with some scripts to create and delete the cluster --- docs/build.md | 4 +- docs/testing-with-kind.md | 61 ++++++------------- e2e-testing/with-kind/create-cluster.sh | 23 +++++++ e2e-testing/with-kind/delete-cluster.sh | 5 ++ e2e-testing/with-kind/kind-config-darwin.yaml | 15 +++++ e2e-testing/with-kind/kind-config-linux.yaml | 15 +++++ 6 files changed, 80 insertions(+), 43 deletions(-) create mode 100755 e2e-testing/with-kind/create-cluster.sh create mode 100755 e2e-testing/with-kind/delete-cluster.sh create mode 100644 e2e-testing/with-kind/kind-config-darwin.yaml create mode 100644 e2e-testing/with-kind/kind-config-linux.yaml diff --git a/docs/build.md b/docs/build.md index 99579c73..5aa3ffd5 100644 --- a/docs/build.md +++ b/docs/build.md @@ -4,7 +4,7 @@ Building the Instana Agent Operator from Source The following command will build the `instana/instana-agent-operator` Docker image locally: ```bash -./mvnw package +./mvnw -C -B clean package docker build -f src/main/docker/Dockerfile.jvm -t instana/instana-agent-operator . ``` @@ -13,6 +13,6 @@ To build the Docker image with GraalVM native image, use the following command: > Note: The native image does not work yet because of [https://github.com/quarkusio/quarkus/issues/3077](https://github.com/quarkusio/quarkus/issues/3077) ```bash -./mvnw package -Pnative -Dnative-image.docker-build=true +./mvnw -C -B clean package -Pnative -Dnative-image.docker-build=true docker build -f src/main/docker/Dockerfile.native -t instana/instana-agent-operator . ``` diff --git a/docs/testing-with-kind.md b/docs/testing-with-kind.md index 64131586..ddf9e714 100644 --- a/docs/testing-with-kind.md +++ b/docs/testing-with-kind.md @@ -10,57 +10,31 @@ Kind (**K**ubernetes **in** **D**ocker) will set up a local cluster where all no Set up a local Kubernetes Cluster with Kind ------------------------------------------- -Create `kind-config.yaml` with the following content (replace `/home` with `/Users` on macOS): - -```yaml -kind: Cluster -apiVersion: kind.sigs.k8s.io/v1alpha3 -nodes: -- role: control-plane - extraMounts: - - containerPath: /hosthome - hostPath: /home -- role: worker - extraMounts: - - containerPath: /hosthome - hostPath: /home -- role: worker - extraMounts: - - containerPath: /hosthome - hostPath: /home -``` - Install [kind](https://kind.sigs.k8s.io/) (a single executable that can be downloaded from the [Github release page](https://github.com/kubernetes-sigs/kind/releases)) and run the following commands to create the cluster: ```sh -kind --config kind-config.yaml create cluster -export KUBECONFIG="$(kind get kubeconfig-path --name="kind")" -kubectl get nodes +./e2e-testing/with-kind/create-cluster.sh ``` You should see a cluster with one control-pane and two worker nodes up and running. -Prepare the Docker Images -------------------------- - -In the `instana-agent-operator` project, build the `instana/instana-agent-operator` Docker image and push it to the local Kind cluster: +This script will also do the following: +- Build the `instana/instana-agent-operator` Docker image locally and load it into the local Kind cluster +- Pull the latest `instana/agent` Docker image locally and load it into the local Kind cluster -```sh -mvn package docker:build -kind load docker-image instana/instana-agent-operator -``` +Install the Operator +-------------------- -Pull the `instana/agent` Docker image and push it to the local Kind cluster: +Follow the steps described in [Install Operator Manually](https://www.instana.com/docs/setup_and_manage/host_agent/on/kubernetes/#install-operator-manually). +If your changes include the `instana-agent-operator.yaml`, you'll need to generate a new version of that file: ```sh -docker pull instana/agent -kind load docker-image instana/agent +./olm/create-artifacts.sh dev olm ``` +Otherwise, you can download `instana-agent-operator.yaml` file from the latest [GitHub release](https://github.com/instana/instana-agent-operator/releases) -Install the Operator --------------------- - -Follow the steps described in [Install Operator Manually](https://docs.instana.io/setup_and_manage/host_agent/on/kubernetes/#install-operator-manually) +Then in either case, change the `imagePullPolicy` for the `Deployment` from `Always` to `IfNotPresent`. +This will ensure that it uses the locally built `instana/instana-agent-operator` image instead of pulling from the remote registry. Expected result --------------- @@ -69,12 +43,17 @@ Expected result kubectl -n instana-agent get pods ``` -should show two instances of the `instana-agent-operator` (see the number of `replicas` configured in `instana-agent-operator-deploy.yaml`), and two instances of `instana-agent` (one on each node in the cluster). +This should show one instance of the `instana-agent-operator` (see the number of `replicas` configured in `olm/operator-resources/instana-agent-operator.yaml`), and two instances of `instana-agent` (one on each worker node in the cluster). + +Delete a node +------------- + +Delete one of the worker nodes that is running the `instana-agent` leader pod. The operator should reassign leadership to another agent pod. +You should see the reassignment if you tail the logs for the operator pod. Clean up -------- ```sh -kind delete cluster -unset KUBECONFIG +./e2e-testing/with-kind/delete-cluster.sh ``` diff --git a/e2e-testing/with-kind/create-cluster.sh b/e2e-testing/with-kind/create-cluster.sh new file mode 100755 index 00000000..521c4a85 --- /dev/null +++ b/e2e-testing/with-kind/create-cluster.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +VERSION=${1:-dev} +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +BASE_DIR="$SCRIPT_DIR/../../" +OS_NAME=$(uname | tr '[:upper:]' '[:lower:]') +KIND_CONFIG_FILE="$SCRIPT_DIR/kind-config-$OS_NAME.yaml" + +printf "%s\n" "Creating cluster with kind-config-$OS_NAME.yaml" +kind --config $KIND_CONFIG_FILE create cluster + +kubectl get nodes + +printf "%s\n" "Build and load Operator image into kind cluster" +./mvnw -C -B clean package +docker build -f $BASE_DIR/src/main/docker/Dockerfile.jvm -t instana/instana-agent-operator:$VERSION $BASE_DIR +kind load docker-image instana/instana-agent-operator + +printf "%s\n" "Load Agent image into kind cluster" +docker pull instana/agent +kind load docker-image instana/agent diff --git a/e2e-testing/with-kind/delete-cluster.sh b/e2e-testing/with-kind/delete-cluster.sh new file mode 100755 index 00000000..a85c68e6 --- /dev/null +++ b/e2e-testing/with-kind/delete-cluster.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +kind delete cluster diff --git a/e2e-testing/with-kind/kind-config-darwin.yaml b/e2e-testing/with-kind/kind-config-darwin.yaml new file mode 100644 index 00000000..726d675c --- /dev/null +++ b/e2e-testing/with-kind/kind-config-darwin.yaml @@ -0,0 +1,15 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + extraMounts: + - containerPath: /hosthome + hostPath: /Users + - role: worker + extraMounts: + - containerPath: /hosthome + hostPath: /Users + - role: worker + extraMounts: + - containerPath: /hosthome + hostPath: /Users diff --git a/e2e-testing/with-kind/kind-config-linux.yaml b/e2e-testing/with-kind/kind-config-linux.yaml new file mode 100644 index 00000000..5730f528 --- /dev/null +++ b/e2e-testing/with-kind/kind-config-linux.yaml @@ -0,0 +1,15 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + extraMounts: + - containerPath: /hosthome + hostPath: /home + - role: worker + extraMounts: + - containerPath: /hosthome + hostPath: /home + - role: worker + extraMounts: + - containerPath: /hosthome + hostPath: /home From 9de49c20c8f3c97d64bbd3a149e8c93ab70299ac Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Mon, 7 Dec 2020 17:04:01 -0600 Subject: [PATCH 4/8] Update the operator-artifacts.jsonnet template to include the version of the instana/instana-agent-operator image tag in the generated instana-agent-operator.yaml This will help ensure that the latest operator image version does not get pulled if it requires the customer to also update the instana-agent-operator.yaml with the latest changes. --- olm/operator-resources/operator-artifacts.jsonnet | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/olm/operator-resources/operator-artifacts.jsonnet b/olm/operator-resources/operator-artifacts.jsonnet index d9f315e1..ab883090 100644 --- a/olm/operator-resources/operator-artifacts.jsonnet +++ b/olm/operator-resources/operator-artifacts.jsonnet @@ -10,9 +10,15 @@ local operatorResourcesWithVersion = std.map(addVersionToMetadataLabels, operato local addVersionToDeploymentSpec(deployment) = deployment + { spec+: { - template+: { metadata+: { labels+: - super.labels + { "app.kubernetes.io/version": version } - }} + template+: { + metadata+: { + labels+: super.labels + { "app.kubernetes.io/version": version } + }, + spec+: + super.spec + { + containers: std.mapWithIndex(function(i, c) if i == 0 then c + {image: c.image + ":" + version} else c, super.containers) + } + } } }; local isDeployment(res) = res.kind == "Deployment"; From d5cd161db258e45aacf30cb09952c1c1d3de4b0c Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Thu, 10 Dec 2020 08:56:54 -0600 Subject: [PATCH 5/8] Do not push the latest tag for the operator Docker image anymore as we'll need to tie the operator image version to the operator yaml version to ensure customers update the operator yaml in order to get the latest image --- Jenkinsfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ecde1351..4f6e6406 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,9 +33,7 @@ pipeline { if (isFullRelease(TAG)) { docker.withRegistry('https://index.docker.io/v1/', '8a04e3ab-c6db-44af-8198-1beb391c98d2') { def image = docker.build("instana/instana-agent-operator:$VERSION", BUILD_ARGS) - image.push() - image.push('latest') } } else { echo "Skipping pushing tag because this is a pre-release or branch." @@ -46,7 +44,6 @@ pipeline { // annoyingly no way to reuse the existing image with docker jenkins plugin. // probably should just pull all of this into a shell script def image = docker.build("scan.connect.redhat.com/ospid-6da7e6aa-00e1-4355-9c15-21d63fb091b6/instana-agent-operator:$VERSION", BUILD_ARGS) - image.push() } } From 610c77b0c9483e68783f71fe64b4ca1bb8fa5468 Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Thu, 10 Dec 2020 09:57:50 -0600 Subject: [PATCH 6/8] Update Instana docs link from docs.instana.io to www.instana.com/docs --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17d60201..24fa7edd 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ This repository contains the Kubernetes Operator to install and manage the Insta There are two ways to install the operator: -* [Creating the required resources manually](https://docs.instana.io/setup_and_manage/host_agent/on/kubernetes/#install-operator-manually) -* [Using the Operator Lifecycle Manager (OLM)](https://docs.instana.io/setup_and_manage/host_agent/on/openshift/#install-operator-via-olm) +* [Creating the required resources manually](https://www.instana.com/docs/setup_and_manage/host_agent/on/kubernetes/#install-operator-manually) +* [Using the Operator Lifecycle Manager (OLM)](https://www.instana.com/docs/setup_and_manage/host_agent/on/openshift/#install-operator-via-olm) ### Configuration -[This documentation section](https://docs.instana.io/setup_and_manage/host_agent/on/kubernetes#operator-configuration) describes configuration options you can set via the Instana Agent CRD and environment variables. +[This documentation section](https://www.instana.com/docs/setup_and_manage/host_agent/on/kubernetes#operator-configuration) describes configuration options you can set via the Instana Agent CRD and environment variables. ### Building From 581a6169197040fcb20a0e5d49d3272c50d053fc Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Thu, 10 Dec 2020 11:10:30 -0600 Subject: [PATCH 7/8] No need to add the version for the instana/instana-agent-operator image within the Deployment when generating the ClusterServiceVersion yaml as we have already placed the version there (and no longer using the latest tag) --- olm/template.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/olm/template.jsonnet b/olm/template.jsonnet index 78429818..5d1b786e 100644 --- a/olm/template.jsonnet +++ b/olm/template.jsonnet @@ -25,7 +25,7 @@ local deployment = std.filterMap(isDeployment, mapDeployment, resources)[0] + { assert std.length(super.containers) == 1 : "Expected exactly 1 container in operator deployment pod", containers: [ super.containers[0] { - image: imagePrefix + super.image + ":" + version, + image: imagePrefix + super.image, [if redhat then "ports"]: [{ containerPort: 9000 }], [if redhat then "env"]: super.env + [ { From f5ac061e4779da49e4f4cc5a12142c611dee52b2 Mon Sep 17 00:00:00 2001 From: Dahlia Bock Date: Thu, 10 Dec 2020 14:18:20 -0600 Subject: [PATCH 8/8] Change the format of the error message that is logged when we fail to update the CustomResource status due to a lack of permissions --- .../java/com/instana/operator/CustomResourceState.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/instana/operator/CustomResourceState.java b/src/main/java/com/instana/operator/CustomResourceState.java index b24869c7..0b12124a 100644 --- a/src/main/java/com/instana/operator/CustomResourceState.java +++ b/src/main/java/com/instana/operator/CustomResourceState.java @@ -133,13 +133,16 @@ private void update() { client.inNamespace(customResource.getMetadata().getNamespace()).createOrReplace(customResource); } catch (Exception e) { StringBuilder errorMessage = new StringBuilder(); - errorMessage.append("Failed to update Custom Resource").append(CRD_NAME).append(name(customResource)); + errorMessage + .append("Failed to update Custom Resource ") + .append("[" + CRD_NAME + "]") + .append(name(customResource) + "."); if (e instanceof KubernetesClientException) { if (((KubernetesClientException)e).getCode() == HTTP_FORBIDDEN) { - errorMessage.append(". Please ensure the operator has the updated cluster role permissions."); + errorMessage.append("Please ensure the operator has the updated cluster role permissions."); } } - LOGGER.warn(errorMessage.toString() + ": " + e.getMessage()); + LOGGER.warn(errorMessage.toString() + " Error: " + e.getMessage()); // No need to System.exit() if we cannot update the status. Ignore this and carry on. } }