Skip to content

Commit 9bff8c2

Browse files
author
eliranb
committed
Update documentation with statefulset
1 parent f343dcc commit 9bff8c2

File tree

10 files changed

+263
-159
lines changed

10 files changed

+263
-159
lines changed

config/samples/agents_v1beta_lightrunjavaagent.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ spec:
77
image: "lightruncom/k8s-operator-init-java-agent-linux:1.7.0-init.0"
88
sharedVolumeName: lightrun-agent-init
99
sharedVolumeMountPath: "/lightrun"
10-
deploymentName: app
10+
# Specify either deploymentName OR statefulSetName, not both
11+
deploymentName: app # Use this for Deployments
12+
#statefulSetName: app-stateful # Use this for StatefulSets
1113
secretName: lightrun-secrets
1214
serverHostname: <lightrun_server> #for saas it will be app.lightrun.com
1315
agentEnvVarName: JAVA_TOOL_OPTIONS

docs/README.md

Lines changed: 178 additions & 116 deletions
Large diffs are not rendered by default.

docs/before_prod.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
### Important to know before deploying to production
22

33
- `LightrunJavaAgent` Customer resource hardly dependent on the secret with `lightrun_key` and `pinned_cert_hash` values. It has do be deployed in the same namespace as the secret.
4-
- `LightrunJavaAgent` CR has to be installed in the same namespace as deployment
5-
- You need to create `LightrunJavaAgent` CR per deployment that you want to patch
6-
- When `creating or deleting CR`, deployment will trigger `recreation of all the pods`, as Pod Template Spec will be changed
7-
- If, for some reason, your cluster will not be able to `download init container` images from https://hub.docker.com/, your deployment will stuck in this state until it won't be resolved. This is the limitation of the init containers
4+
- `LightrunJavaAgent` CR has to be installed in the same namespace as the target resource (Deployment or StatefulSet)
5+
- You need to create `LightrunJavaAgent` CR per resource (Deployment or StatefulSet) that you want to patch
6+
- When `creating or deleting CR`, the target resource will trigger `recreation of all the pods`, as Pod Template Spec will be changed
7+
- If, for some reason, your cluster will not be able to `download init container` images from https://hub.docker.com/, your target resource will stuck in this state until it won't be resolved. This is the limitation of the init containers
88
- If you will change `secret` values, `agentConfig` or `agentTags`, operator will update Config Map with that data and trigger recreation of the pods to apply new config of the agent
99
- Always check `release notes` before upgrading the operator. If CRD fields was changed you'll need to act accordingly during the upgrade
1010
- You can't have `duplicate ENV` variable in the container spec.
@@ -17,4 +17,14 @@
1717
name: <Your deployment name>
1818
jqPathExpressions:
1919
- '.spec.template.spec.containers[] | select(.name == "<your container name>").env[] | select(.name == "JAVA_TOOL_OPTIONS")'
20+
```
21+
22+
For StatefulSets, use:
23+
```yaml
24+
ignoreDifferences:
25+
- group: apps
26+
kind: StatefulSet
27+
name: <Your statefulset name>
28+
jqPathExpressions:
29+
- '.spec.template.spec.containers[] | select(.name == "<your container name>").env[] | select(.name == "JAVA_TOOL_OPTIONS")'
2030
```

docs/custom_resource.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ spec:
1616
# Mount path where volume will be parked. Various distributions may have it's limitations.
1717
# For example you can't mount volumes to any path except `/tmp` when using AWS Fargate
1818
sharedVolumeMountPath: "/lightrun"
19+
# NOTE: Specify either deploymentName OR statefulSetName, not both
1920
# Name of the deployment that you are going to patch.
2021
# Has to be in the same namespace
2122
deploymentName: app
23+
# Name of the statefulset that you are going to patch.
24+
# Has to be in the same namespace
25+
# statefulSetName: app-stateful
2226
# Name of the secret where agent will take `lightrun_key` and `pinned_cert_hash` from
2327
# Has to be in the same namespace
2428
secretName: lightrun-secrets
@@ -54,5 +58,4 @@ stringData:
5458
# Server certificate hash. It is ensuring that agent is connected to the right Lightrun server
5559
pinned_cert_hash: <pinned_cert_hash>
5660
kind: Secret
57-
type: Opaque
58-
```
61+
type: Opaque

docs/how.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
(subject to how it's been installed).
88
Every event related to these CRs triggers the reconcile loop of the controller. You can find logic of this loop [here](reconcile_loop.excalidraw.png)
99
- When triggered, the controller performs several actions:
10-
- Check if it has access to deployment
10+
- Check if it has access to the target resource (Deployment or StatefulSet)
1111
- Fetch data from the CR secret
1212
- Create config map with agent config from CR data
13-
- Patch the deployment:
13+
- Patch the target resource (Deployment or StatefulSet):
1414
- insert init container
1515
- add volume
1616
- map that volume to the specified container
1717
- add/update specified ENV variable in order to let Java know where agent files are found (the mapped volume)
18-
- After deployment is patched, k8s will `recreate all the pods` in the deployment. New Pods will be initialized with the Lightrun agent
19-
- If user deletes the `LightrunJavaAgent` CR, the Controller will roll back all the changes to deployment. This will trigger `recreation of all pods` again
18+
- After the target resource is patched, k8s will `recreate all the pods` in the Deployment or StatefulSet. New Pods will be initialized with the Lightrun agent
19+
- If user deletes the `LightrunJavaAgent` CR, the Controller will roll back all the changes to the target resource. This will trigger `recreation of all pods` again
2020
- [High level diagram](resource_relations.excalidraw.png) of resources created/edited by the operator

examples/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec:
1919
env:
2020
- name: JAVA_TOOL_OPTIONS
2121
value: -Djava.net.preferIPv4Stack=true
22-
image: lightrun-k8s-operator-registry:5000/operator-demo-app:latest
22+
image: lightruncom/operator-demo-app
2323
securityContext:
2424
allowPrivilegeEscalation: false
2525
capabilities:

examples/lightrun-secret.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: v1
3+
metadata:
4+
name: lightrun-secrets
5+
stringData:
6+
# Lightrun key you can take from the server UI at the "setup agent" step
7+
lightrun_key: <lightrun_key>
8+
# Server certificate hash. It is ensuring that agent is connected to the right Lightrun server
9+
pinned_cert_hash: <pinned_cert_hash>
10+
kind: Secret
11+
type: Opaque

examples/lightrunjavaagent.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: agents.lightrun.com/v1beta
22
kind: LightrunJavaAgent
33
metadata:
4-
name: example-cr
4+
name: example-deployment-cr
55
spec:
66
###############################################################################################
77
# Fields that you need to change if you want to try operator with your own deployment
@@ -30,7 +30,7 @@ spec:
3030
# agent version - first part of the tag (1.7.0)
3131
# init container sub-version - last part of the tag (init.0)
3232
# List of available images in the README.md
33-
image: "lightrun-k8s-operator-registry:5000/lightrun-init-agent:latest"
33+
image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
3434
# Volume name in case you have some convention in the names
3535
sharedVolumeName: lightrun-agent-init
3636
# Mount path where volume will be parked. Various distributions may have it's limitations.
@@ -59,15 +59,3 @@ spec:
5959
- latest
6060
# Agent name. If not provided, pod name will be used
6161
#agentName: "operator-test-agent"
62-
63-
---
64-
apiVersion: v1
65-
metadata:
66-
name: lightrun-secrets
67-
stringData:
68-
# Lightrun key you can take from the server UI at the "setup agent" step
69-
lightrun_key: 65cf112e-03f5-42da-a2f3-3c46d368872b
70-
# Server certificate hash. It is ensuring that agent is connected to the right Lightrun server
71-
pinned_cert_hash: ee80811b38e7e6c2dc4cc372cbea86bd86b446b012e427f2e19bf094afba5d12
72-
kind: Secret
73-
type: Opaque
Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,60 @@
11
apiVersion: agents.lightrun.com/v1beta
22
kind: LightrunJavaAgent
33
metadata:
4-
name: statefulset-agent
4+
name: example-statefulset-cr
55
spec:
6-
# Specify the StatefulSet to instrument
6+
###############################################################################################
7+
# Fields that you need to change if you want to try operator with your own statefulset
8+
###############################################################################################
9+
# Name of the statefulset that you are going to patch.
10+
# Has to be in the same namespace
711
statefulSetName: "sample-statefulset"
8-
# List of container names inside the pod to instrument
12+
# List of container names inside the pod of the statefulset
13+
# If container not mentioned here it will be not patched
914
containerSelector:
1015
- app
11-
# Init container with the Lightrun agent
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+
# Fields that are mostly fine with default values for most deployments
25+
###############################################################################################
26+
# Init container with agent. Differes by agent version and platform that it will be used for. For now supported platforms are `linux` and `alpine`
1227
initContainer:
13-
image: "lightrun-k8s-operator-registry:5000/lightrun-init-agent:latest"
28+
# parts that may vary here are
29+
# platform - `linux/alpine`
30+
# agent version - first part of the tag (1.7.0)
31+
# init container sub-version - last part of the tag (init.0)
32+
# List of available images in the README.md
33+
image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
34+
# Volume name in case you have some convention in the names
1435
sharedVolumeName: "lightrun-agent"
1536
sharedVolumeMountPath: "/lightrun"
16-
# Reference to the Secret with Lightrun credentials
17-
secretName: "lightrun-secrets"
18-
# Environment variable to patch with the agent path
19-
agentEnvVarName: "JAVA_TOOL_OPTIONS"
20-
# Lightrun server hostname
21-
serverHostname: "app.lightrun.com"
22-
# Optional agent configuration
37+
# Hostname of the server. Will be different for on-prem ans single-tenant installations
38+
# For saas it is app.lightrun.com
39+
serverHostname: app.lightrun.com
40+
# Env var that will be patched with agent path.
41+
# If your application not using any, recommended option is to use "JAVA_TOOL_OPTIONS"
42+
# Also may be "_JAVA_OPTIONS", "JAVA_OPTS"
43+
# There are also different variations if using Maven - "MAVEN_OPTS", and so on
44+
# You can find more info here: https://docs.lightrun.com/jvm/agent/
2345
agentConfig:
2446
max_log_cpu_cost: "2"
25-
# Tags that will appear in the Lightrun UI
47+
# agentCliFlags is used if need to pass additional flags to the agent,
48+
# that are not part of configuration file.
49+
# https://docs.lightrun.com/jvm/agent-configuration/#additional-command-line-flags
50+
# Example below
51+
# agentCliFlags: --lightrun_extra_class_path=<PATH_TO_JAR>:<PATH_TO_JAR>,lightrun_init_wait_time_ms
52+
53+
# Tags that agent will be using. You'll see them in the UI and in the IDE plugin as well
2654
agentTags:
2755
- operator
2856
- example
2957
- latest
3058
- statefulset
31-
# Optional agent name (if not set, pod name will be used)
32-
agentName: "stateful-java-app"
59+
# Agent name. If not provided, pod name will be used
60+
#agentName: "operator-test-agent"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ spec:
1919
- name: app
2020
env:
2121
- name: JAVA_TOOL_OPTIONS
22-
value: -Djava.net.preferIPv4Stack=true
23-
image: lightrun-k8s-operator-registry:5000/operator-demo-app:latest
22+
value: -Djava.net.preferIPv4Stack=true, -Xmx1024m
23+
image: lightruncom/operator-demo-app
2424
securityContext:
2525
allowPrivilegeEscalation: false
2626
capabilities:

0 commit comments

Comments
 (0)