Skip to content

Commit 5a77aaf

Browse files
author
Leonid Podolinskiy
authored
update docs and comments (#7)
* update docs and comments * update test data according to example deployment
1 parent 1b2c921 commit 5a77aaf

File tree

11 files changed

+61
-51
lines changed

11 files changed

+61
-51
lines changed

.github/workflows/e2e.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
printf "Install helm chart\n"
129129
helm install -n lightrun-k8s-operator lightrun-k8s-operator ./helm-chart -f .github/workflows/tests_data/chart_values.yaml
130130
131-
kubectl wait deployment app --for condition=Available=True --timeout=90s
131+
kubectl wait deployment sample-deployment --for condition=Available=True --timeout=90s
132132
133133
kubectl get deployments -n lightrun-k8s-operator
134134
kubectl get pods -n lightrun-k8s-operator
@@ -137,7 +137,7 @@ jobs:
137137
138138
139139
kubectl apply -f .github/workflows/tests_data/lightrunjavaagent.yaml
140-
kubectl wait deployment app --for condition=Available=True --timeout=90s
140+
kubectl wait deployment sample-deployment --for condition=Available=True --timeout=90s
141141
142142
143143
printf "Wait 1 minute\n"
@@ -149,13 +149,13 @@ jobs:
149149
150150
151151
printf "\n\nAgent INFO log\n"
152-
kubectl exec -t deploy/app -c app -- cat /tmp/lightrun_java_agent.INFO
152+
kubectl exec -t deploy/sample-deployment -c app -- cat /tmp/lightrun_java_agent.INFO
153153
printf "\n\nAgent ERROR log\n"
154-
kubectl exec -t deploy/app -c app -- cat /tmp/lightrun_java_agent.ERROR || true
154+
kubectl exec -t deploy/sample-deployment -c app -- cat /tmp/lightrun_java_agent.ERROR || true
155155
156156
157157
printf "\nSearching for "registered" in INFO log\n"
158-
if kubectl exec -t deploy/app -c app -- cat /tmp/lightrun_java_agent.INFO | grep Debuggee |grep registered > /dev/null; then
158+
if kubectl exec -t deploy/sample-deployment -c app -- cat /tmp/lightrun_java_agent.INFO | grep Debuggee |grep registered > /dev/null; then
159159
printf "\n----------------\nAgent registered succesfully!\n----------------\n"
160160
else
161161
printf "\n----------------\nAgent failed to register!\n----------------\n"
@@ -186,7 +186,7 @@ jobs:
186186
kubectl apply -f .github/workflows/tests_data/lightrunjavaagent.yaml
187187
188188
sleep 5
189-
kubectl describe deployment app
189+
kubectl describe deployment sample-deployment
190190
191191
printf "Controller logs\n\n\n"
192192
kubectl logs --tail=500 -l control-plane=controller-manager -n lightrun-k8s-operator

.github/workflows/tests_data/lightrunjavaagent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
image: "lightruncom/k8s-operator-init-java-agent-linux:1.8.5-init.1"
88
sharedVolumeName: lightrun-agent-init
99
sharedVolumeMountPath: "/lightrun"
10-
deploymentName: app
10+
deploymentName: sample-deployment
1111
secretName: lightrun-secrets
1212
serverHostname: dogfood.internal.lightrun.com
1313
agentEnvVarName: JAVA_TOOL_OPTIONS

config/crd/bases/agents.lightrun.com_lightrunjavaagents.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ spec:
125125
description: "Condition contains details for one aspect of the current
126126
state of this API Resource. --- This struct is intended for direct
127127
use as an array at the field path .status.conditions. For example,
128-
type FooStatus struct{ // Represents the observations of a foo's
129-
current state. // Known .status.conditions.type are: \"Available\",
128+
\n type FooStatus struct{ // Represents the observations of a
129+
foo's current state. // Known .status.conditions.type are: \"Available\",
130130
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
131131
// +listType=map // +listMapKey=type Conditions []metav1.Condition
132132
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"

config/samples/operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ spec:
131131
description: "Condition contains details for one aspect of the current
132132
state of this API Resource. --- This struct is intended for direct
133133
use as an array at the field path .status.conditions. For example,
134-
type FooStatus struct{ // Represents the observations of a foo's
135-
current state. // Known .status.conditions.type are: \"Available\",
134+
\n type FooStatus struct{ // Represents the observations of a
135+
foo's current state. // Known .status.conditions.type are: \"Available\",
136136
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
137137
// +listType=map // +listMapKey=type Conditions []metav1.Condition
138138
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"

controllers/lightrunjavaagent_controller_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,15 @@ var _ = Describe("LightrunJavaAgent controller", func() {
572572
Expect(k8sClient.Create(ctx, &depl)).Should(Succeed())
573573
})
574574

575+
It("Should have successful status of existing CR", func() {
576+
Eventually(func() bool {
577+
if err := k8sClient.Get(ctx, lrAgentRequest2, &lrAgent2); err != nil {
578+
return false
579+
}
580+
return lrAgent2.Status.DeploymentStatus == "Ready"
581+
}).Should(BeTrue())
582+
})
583+
575584
It("prepare new CR with patched deployment", func() {
576585
By("Creating new CR")
577586
lrAgent3 := agentsv1beta.LightrunJavaAgent{

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ To set up the Lightrun K8s operator:
4646
kubectl create namespace lightrun-operator
4747
kubectl create namespace lightrun-agent-test
4848
```
49+
_`lightrun-operator` namespace is hardcoded in the example `operator.yaml` due to Role and RoleBinding objects_
50+
_If you want to deploy operator to a different namespace - you can use helm chart_
4951

5052
2. Deploy operator to the operator namesapce
5153
```sh

examples/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: app
4+
name: sample-deployment
55
labels:
66
app: app
77
spec:

examples/lightrunjavaagent.yaml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,49 @@ kind: LightrunJavaAgent
33
metadata:
44
name: example-cr
55
spec:
6+
###############################################################################################
7+
# Fields that you need to change if you want to try operator with your own deployment
8+
###############################################################################################
9+
# Name of the deployment that you are going to patch.
10+
# Has to be in the same namespace
11+
deploymentName: sample-deployment
12+
# List of container names inside the pod of the deployment
13+
# If container not mentioned here it will be not patched
14+
containerSelector:
15+
- app
16+
# Agent config will override default configuration with provided values
17+
# You can find list of available options here https://docs.lightrun.com/jvm/agent-configuration/
18+
agentEnvVarName: JAVA_TOOL_OPTIONS
19+
# Name of the secret where agent will take `lightrun_key` and `pinned_cert_hash` from
20+
# Has to be in the same namespace
21+
secretName: lightrun-secrets
22+
23+
24+
###############################################################################################
25+
# Fields that are mostly fine with default values for most deployments
26+
###############################################################################################
627
# Init container with agent. Differes by agent version and platform that it will be used for. For now supported platforms are `linux` and `alpine`
728
initContainer:
829
# parts that may vary here are
930
# platform - `linux/alpine`
1031
# agent version - first part of the tag (1.7.0)
1132
# init container sub-version - last part of the tag (init.0)
12-
image: "lightruncom/k8s-operator-init-java-agent-linux:1.8.3-init.0"
33+
image: "lightruncom/k8s-operator-init-java-agent-linux:1.8.5-init.1"
1334
# Volume name in case you have some convention in the names
1435
sharedVolumeName: lightrun-agent-init
1536
# Mount path where volume will be parked. Various distributions may have it's limitations.
1637
# For example you can't mount volumes to any path except `/tmp` when using AWS Fargate
1738
sharedVolumeMountPath: "/lightrun"
18-
# Name of the deployment that you are going to patch.
19-
# Has to be in the same namespace
20-
deploymentName: app
21-
# Name of the secret where agent will take `lightrun_key` and `pinned_cert_hash` from
22-
# Has to be in the same namespace
23-
secretName: lightrun-secrets
2439
# Hostname of the server. Will be different for on-prem ans single-tenant installations
25-
# For saas it will be app.lightrun.com
26-
serverHostname: <lightrun_server>
40+
# For saas it is app.lightrun.com
41+
serverHostname: app.lightrun.com
2742
# Env var that will be patched with agent path.
2843
# If your application not using any, recommended option is to use "JAVA_TOOL_OPTIONS"
2944
# Also may be "_JAVA_OPTIONS", "JAVA_OPTS"
3045
# There are also different variations if using Maven - "MAVEN_OPTS", and so on
3146
# You can find more info here: https://docs.lightrun.com/jvm/agent/
32-
agentEnvVarName: JAVA_TOOL_OPTIONS
33-
# Agent config will override default configuration with provided values
34-
# You can find list of available options here https://docs.lightrun.com/jvm/agent-configuration/
3547
agentConfig:
3648
max_log_cpu_cost: "2"
37-
3849
# agentCliFlags is used if need to pass additional flags to the agent,
3950
# that are not part of configuration file.
4051
# https://docs.lightrun.com/jvm/agent-configuration/#additional-command-line-flags
@@ -45,13 +56,10 @@ spec:
4556
agentTags:
4657
- operator
4758
- example
48-
- 1.8.3
59+
- 1.8.5
4960
# Agent name. If not provided, pod name will be used
5061
#agentName: "operator-test-agent"
51-
# List of container names inside the pod of the deployment
52-
# If container not mentioned here it will be not patched
53-
containerSelector:
54-
- app
62+
5563
---
5664
apiVersion: v1
5765
metadata:

examples/operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ spec:
126126
description: "Condition contains details for one aspect of the current
127127
state of this API Resource. --- This struct is intended for direct
128128
use as an array at the field path .status.conditions. For example,
129-
type FooStatus struct{ // Represents the observations of a foo's
130-
current state. // Known .status.conditions.type are: \"Available\",
129+
\n type FooStatus struct{ // Represents the observations of a
130+
foo's current state. // Known .status.conditions.type are: \"Available\",
131131
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
132132
// +listType=map // +listMapKey=type Conditions []metav1.Condition
133133
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"

helm-chart/Chart.yaml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,22 @@ annotations:
3636
metadata:
3737
name: example-cr
3838
spec:
39+
deploymentName: sample-deployment
40+
containerSelector:
41+
- app
42+
secretName: lightrun-secrets
43+
serverHostname: app.lightrun.com
44+
agentEnvVarName: JAVA_TOOL_OPTIONS
3945
initContainer:
4046
image: "lightruncom/k8s-operator-init-java-agent-linux:1.8.5-init.1"
4147
sharedVolumeName: lightrun-agent-init
4248
sharedVolumeMountPath: "/lightrun"
43-
deploymentName: app
44-
secretName: lightrun-secrets
45-
serverHostname: app.lightrun.com
46-
agentEnvVarName: JAVA_TOOL_OPTIONS
47-
agentConfig:
48-
max_log_cpu_cost: "2"
4949
agentTags:
5050
- operator
5151
- example
5252
- 1.8.3
53-
containerSelector:
54-
- app
55-
---
56-
apiVersion: v1
57-
metadata:
58-
name: lightrun-secrets
59-
stringData:
60-
lightrun_key: <lightrun_key_from_ui>
61-
pinned_cert_hash: <pinned_cert_hash>
62-
kind: Secret
63-
type: Opaque
53+
54+
6455
6556
artifacthub.io/license: Apache-2.0
6657
artifacthub.io/links: |

0 commit comments

Comments
 (0)