Skip to content

DEVOPS-2689-extend-k-8-s-operator-support-to-include-stateful-sets #43

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
65d209c
Phase 1: CRD and Initial Structure
Apr 29, 2025
e9b798a
Phase 1: update chart and config examples
Apr 29, 2025
f343dcc
Phase 2: StatefulSet Implementation
Apr 29, 2025
9bff8c2
Update documentation with statefulset
Apr 29, 2025
f000a8e
Phase 3: Testing
Apr 29, 2025
4f3ebf2
Fix formatting in lightrun-secret.yaml by adding a newline at the end…
Apr 29, 2025
0ee5505
Add newline at the end of statefulset-lightrunjavaagent.yaml for cons…
Apr 29, 2025
2cf6070
Remove redundant memory option from JAVA_TOOL_OPTIONS in statefulset.…
Apr 29, 2025
585ac87
Remove trailing whitespace in statefulset-lightrunjavaagent.yaml
Apr 29, 2025
dc55550
Revert WorkloadStatus field to DeploymentStatus to keep backward comp…
Apr 30, 2025
de2ba95
removing TODO comment regarding DeploymentStatus field
May 4, 2025
1d5c1f2
Update CRD and example files to replace 'WorkloadStatus' with 'Deploy…
May 4, 2025
191419b
Refactor config map data hash calculation in lightrunjavaagent_contro…
May 4, 2025
9115f02
Add WorkloadType and WorkloadName support in lightrunjavaagent_types.…
May 13, 2025
124b19f
Update instance status field from DeploymentStatus to WorkloadStatus …
May 13, 2025
21978cb
Refactor LightrunJavaAgent reconciliation logic to support new Worklo…
May 13, 2025
a104886
Update LightrunJavaAgent controller tests to reflect changes in workl…
May 14, 2025
4a18f67
Update .gitignore to include macOS .DS_Store files and remove depreca…
May 14, 2025
b8d4a04
Update CRDs and example files to replace Deployment and StatefulSet r…
May 14, 2025
2df1dbc
Enhance documentation in lightrunjavaagent_types.go by clarifying the…
May 14, 2025
56e5f55
Clarify workloadName field description in CRDs and example files to s…
May 14, 2025
05c6fb9
Update LightrunJavaAgent configuration files to replace deploymentNam…
May 14, 2025
44ed3c3
Deprecate DeploymentName field in LightrunJavaAgentSpec, updating doc…
May 14, 2025
924923b
Deprecate deploymentName field in LightrunJavaAgent configuration fil…
May 14, 2025
8c1ad6e
Fix formatting in custom_resource.md by adding a newline at the end o…
May 14, 2025
bb8334d
keep deploymetStatus for bc
May 20, 2025
a712847
simplify determineWorkloadType function per PR's feedback
May 20, 2025
5e1b54d
add checks for missing workloadName in reconcileDeployment and reconc…
May 20, 2025
b948101
update crds
May 20, 2025
52c042c
Improve error messages in reconcileDeployment and reconcileStatefulSe…
May 21, 2025
d462f06
Remove deprecated printcolumn for deploymentName in LightrunJavaAgent…
May 21, 2025
1af59a3
Remove deprecated deploymentName print column from LightrunJavaAgent …
May 21, 2025
33831b3
Update error message in LightrunJavaAgent controller tests to reflect…
May 21, 2025
22505e3
Refactor determineWorkloadType function to improve configuration vali…
May 21, 2025
2a68b3b
Refactor determineWorkloadType function to streamline workload type d…
May 21, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ coverage-report.html
*.swo
*~
.vscode
# macOS
.DS_Store
30 changes: 26 additions & 4 deletions api/v1beta/lightrunjavaagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ import (
// Important: Run "make" to regenerate code after modifying this file
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// WorkloadType defines the type of workload that can be patched
// +kubebuilder:validation:Enum=Deployment;StatefulSet
type WorkloadType string

const (
// WorkloadTypeDeployment represents a Kubernetes Deployment
WorkloadTypeDeployment WorkloadType = "Deployment"
// WorkloadTypeStatefulSet represents a Kubernetes StatefulSet
WorkloadTypeStatefulSet WorkloadType = "StatefulSet"
)

type InitContainer struct {
// Name of the volume that will be added to pod
SharedVolumeName string `json:"sharedVolumeName"`
Expand All @@ -38,8 +49,17 @@ type LightrunJavaAgentSpec struct {
ContainerSelector []string `json:"containerSelector"`
InitContainer InitContainer `json:"initContainer"`

//Name of the Deployment that will be patched
DeploymentName string `json:"deploymentName"`
// Name of the Deployment that will be patched. Deprecated, use WorkloadName and WorkloadType instead
// +optional
DeploymentName string `json:"deploymentName,omitempty"`

// Name of the Workload that will be patched. workload can be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
// +optional
WorkloadName string `json:"workloadName,omitempty"`

// Type of the workload that will be patched supported values are Deployment, StatefulSet
// +optional
WorkloadType WorkloadType `json:"workloadType,omitempty"`

//Name of the Secret in the same namespace contains lightrun key and conmpany id
SecretName string `json:"secretName"`
Expand Down Expand Up @@ -76,14 +96,16 @@ type LightrunJavaAgentSpec struct {
type LightrunJavaAgentStatus struct {
LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
WorkloadStatus string `json:"workloadStatus,omitempty"`
DeploymentStatus string `json:"deploymentStatus,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=lrja
//+kubebuilder:printcolumn:priority=0,name=Deployment,type=string,JSONPath=".spec.deploymentName",description="Deployment name",format=""
//+kubebuilder:printcolumn:priority=0,name="Status",type=string,JSONPath=".status.deploymentStatus",description="Status of Deployment Reconciliation",format=""
//+kubebuilder:printcolumn:priority=0,name=Workload,type=string,JSONPath=".spec.workloadName",description="Workload name",format=""
//+kubebuilder:printcolumn:priority=0,name=Type,type=string,JSONPath=".spec.workloadType",description="Workload type",format=""
//+kubebuilder:printcolumn:priority=0,name="Status",type=string,JSONPath=".status.workloadStatus",description="Status of Workload Reconciliation",format=""
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// LightrunJavaAgent is the Schema for the lightrunjavaagents API
Expand Down
31 changes: 24 additions & 7 deletions charts/lightrun-operator/crds/lightrunjavaagent_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
jsonPath: .spec.deploymentName
name: Deployment
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
type: string
- description: Status of Deployment Reconciliation
jsonPath: .status.deploymentStatus
- description: Workload type
jsonPath: .spec.workloadType
name: Type
type: string
- description: Status of Workload Reconciliation
jsonPath: .status.workloadStatus
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
Expand Down Expand Up @@ -85,7 +89,8 @@ spec:
type: string
type: array
deploymentName:
description: Name of the Deployment that will be patched
description: Name of the Deployment that will be patched. Deprecated,
use WorkloadName and WorkloadType instead
type: string
initContainer:
properties:
Expand Down Expand Up @@ -114,11 +119,21 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
type: string
workloadType:
description: Type of the workload that will be patched supported values
are Deployment, StatefulSet
enum:
- Deployment
- StatefulSet
type: string
required:
- agentEnvVarName
- agentTags
- containerSelector
- deploymentName
- initContainer
- secretName
- serverHostname
Expand Down Expand Up @@ -200,6 +215,8 @@ spec:
lastScheduleTime:
format: date-time
type: string
workloadStatus:
type: string
type: object
type: object
served: true
Expand Down
9 changes: 9 additions & 0 deletions charts/lightrun-operator/generated/rbac_manager_rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
- list
- patch
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- get
- list
- patch
- watch
- apiGroups:
- ""
resources:
Expand Down
31 changes: 24 additions & 7 deletions config/crd/bases/agents.lightrun.com_lightrunjavaagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
jsonPath: .spec.deploymentName
name: Deployment
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
type: string
- description: Status of Deployment Reconciliation
jsonPath: .status.deploymentStatus
- description: Workload type
jsonPath: .spec.workloadType
name: Type
type: string
- description: Status of Workload Reconciliation
jsonPath: .status.workloadStatus
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
Expand Down Expand Up @@ -86,7 +90,8 @@ spec:
type: string
type: array
deploymentName:
description: Name of the Deployment that will be patched
description: Name of the Deployment that will be patched. Deprecated,
use WorkloadName and WorkloadType instead
type: string
initContainer:
properties:
Expand Down Expand Up @@ -115,11 +120,21 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
type: string
workloadType:
description: Type of the workload that will be patched supported values
are Deployment, StatefulSet
enum:
- Deployment
- StatefulSet
type: string
required:
- agentEnvVarName
- agentTags
- containerSelector
- deploymentName
- initContainer
- secretName
- serverHostname
Expand Down Expand Up @@ -201,6 +216,8 @@ spec:
lastScheduleTime:
format: date-time
type: string
workloadStatus:
type: string
type: object
type: object
served: true
Expand Down
9 changes: 9 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ rules:
- list
- patch
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- get
- list
- patch
- watch
- apiGroups:
- ""
resources:
Expand Down
3 changes: 2 additions & 1 deletion config/samples/agents_v1beta_lightrunjavaagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ spec:
image: "lightruncom/k8s-operator-init-java-agent-linux:1.7.0-init.0"
sharedVolumeName: lightrun-agent-init
sharedVolumeMountPath: "/lightrun"
deploymentName: app
workloadName: app
workloadType: Deployment
secretName: lightrun-secrets
serverHostname: <lightrun_server> #for saas it will be app.lightrun.com
agentEnvVarName: JAVA_TOOL_OPTIONS
Expand Down
40 changes: 33 additions & 7 deletions config/samples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Deployment name
jsonPath: .spec.deploymentName
name: Deployment
- description: Workload name
jsonPath: .spec.workloadName
name: Workload
type: string
- description: Status of Deployment Reconciliation
jsonPath: .status.deploymentStatus
- description: Workload type
jsonPath: .spec.workloadType
name: Type
type: string
- description: Status of Workload Reconciliation
jsonPath: .status.workloadStatus
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
Expand Down Expand Up @@ -97,7 +101,8 @@ spec:
type: string
type: array
deploymentName:
description: Name of the Deployment that will be patched
description: Name of the Deployment that will be patched. Deprecated,
use WorkloadName and WorkloadType instead
type: string
initContainer:
properties:
Expand Down Expand Up @@ -126,11 +131,21 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
type: string
workloadType:
description: Type of the workload that will be patched supported values
are Deployment, StatefulSet
enum:
- Deployment
- StatefulSet
type: string
required:
- agentEnvVarName
- agentTags
- containerSelector
- deploymentName
- initContainer
- secretName
- serverHostname
Expand Down Expand Up @@ -212,6 +227,8 @@ spec:
lastScheduleTime:
format: date-time
type: string
workloadStatus:
type: string
type: object
type: object
served: true
Expand Down Expand Up @@ -315,6 +332,15 @@ rules:
- list
- patch
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- get
- list
- patch
- watch
- apiGroups:
- ""
resources:
Expand Down
Loading
Loading