Skip to content

Commit 2be38da

Browse files
authored
DEVOPS-2689-extend-k-8-s-operator-support-to-include-stateful-sets (#43)
1 parent 365e952 commit 2be38da

21 files changed

+1208
-230
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ coverage-report.html
2525
*.swo
2626
*~
2727
.vscode
28+
# macOS
29+
.DS_Store

api/v1beta/lightrunjavaagent_types.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ import (
2323
// Important: Run "make" to regenerate code after modifying this file
2424
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525

26+
// WorkloadType defines the type of workload that can be patched
27+
// +kubebuilder:validation:Enum=Deployment;StatefulSet
28+
type WorkloadType string
29+
30+
const (
31+
// WorkloadTypeDeployment represents a Kubernetes Deployment
32+
WorkloadTypeDeployment WorkloadType = "Deployment"
33+
// WorkloadTypeStatefulSet represents a Kubernetes StatefulSet
34+
WorkloadTypeStatefulSet WorkloadType = "StatefulSet"
35+
)
36+
2637
type InitContainer struct {
2738
// Name of the volume that will be added to pod
2839
SharedVolumeName string `json:"sharedVolumeName"`
@@ -38,8 +49,17 @@ type LightrunJavaAgentSpec struct {
3849
ContainerSelector []string `json:"containerSelector"`
3950
InitContainer InitContainer `json:"initContainer"`
4051

41-
//Name of the Deployment that will be patched
42-
DeploymentName string `json:"deploymentName"`
52+
// Name of the Deployment that will be patched. Deprecated, use WorkloadName and WorkloadType instead
53+
// +optional
54+
DeploymentName string `json:"deploymentName,omitempty"`
55+
56+
// Name of the Workload that will be patched. workload can be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
57+
// +optional
58+
WorkloadName string `json:"workloadName,omitempty"`
59+
60+
// Type of the workload that will be patched supported values are Deployment, StatefulSet
61+
// +optional
62+
WorkloadType WorkloadType `json:"workloadType,omitempty"`
4363

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

82103
//+kubebuilder:object:root=true
83104
//+kubebuilder:subresource:status
84105
//+kubebuilder:resource:shortName=lrja
85-
//+kubebuilder:printcolumn:priority=0,name=Deployment,type=string,JSONPath=".spec.deploymentName",description="Deployment name",format=""
86-
//+kubebuilder:printcolumn:priority=0,name="Status",type=string,JSONPath=".status.deploymentStatus",description="Status of Deployment Reconciliation",format=""
106+
//+kubebuilder:printcolumn:priority=0,name=Workload,type=string,JSONPath=".spec.workloadName",description="Workload name",format=""
107+
//+kubebuilder:printcolumn:priority=0,name=Type,type=string,JSONPath=".spec.workloadType",description="Workload type",format=""
108+
//+kubebuilder:printcolumn:priority=0,name="Status",type=string,JSONPath=".status.workloadStatus",description="Status of Workload Reconciliation",format=""
87109
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
88110

89111
// LightrunJavaAgent is the Schema for the lightrunjavaagents API

charts/lightrun-operator/crds/lightrunjavaagent_crd.yaml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ spec:
1616
scope: Namespaced
1717
versions:
1818
- additionalPrinterColumns:
19-
- description: Deployment name
20-
jsonPath: .spec.deploymentName
21-
name: Deployment
19+
- description: Workload name
20+
jsonPath: .spec.workloadName
21+
name: Workload
2222
type: string
23-
- description: Status of Deployment Reconciliation
24-
jsonPath: .status.deploymentStatus
23+
- description: Workload type
24+
jsonPath: .spec.workloadType
25+
name: Type
26+
type: string
27+
- description: Status of Workload Reconciliation
28+
jsonPath: .status.workloadStatus
2529
name: Status
2630
type: string
2731
- jsonPath: .metadata.creationTimestamp
@@ -85,7 +89,8 @@ spec:
8589
type: string
8690
type: array
8791
deploymentName:
88-
description: Name of the Deployment that will be patched
92+
description: Name of the Deployment that will be patched. Deprecated,
93+
use WorkloadName and WorkloadType instead
8994
type: string
9095
initContainer:
9196
properties:
@@ -114,11 +119,21 @@ spec:
114119
Lightrun server hostname that will be used for downloading an agent
115120
Key and company id in the secret has to be taken from this server as well
116121
type: string
122+
workloadName:
123+
description: Name of the Workload that will be patched. workload can
124+
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
125+
type: string
126+
workloadType:
127+
description: Type of the workload that will be patched supported values
128+
are Deployment, StatefulSet
129+
enum:
130+
- Deployment
131+
- StatefulSet
132+
type: string
117133
required:
118134
- agentEnvVarName
119135
- agentTags
120136
- containerSelector
121-
- deploymentName
122137
- initContainer
123138
- secretName
124139
- serverHostname
@@ -200,6 +215,8 @@ spec:
200215
lastScheduleTime:
201216
format: date-time
202217
type: string
218+
workloadStatus:
219+
type: string
203220
type: object
204221
type: object
205222
served: true

charts/lightrun-operator/generated/rbac_manager_rules.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
- list
3434
- patch
3535
- watch
36+
- apiGroups:
37+
- apps
38+
resources:
39+
- statefulsets
40+
verbs:
41+
- get
42+
- list
43+
- patch
44+
- watch
3645
- apiGroups:
3746
- ""
3847
resources:

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ spec:
1717
scope: Namespaced
1818
versions:
1919
- additionalPrinterColumns:
20-
- description: Deployment name
21-
jsonPath: .spec.deploymentName
22-
name: Deployment
20+
- description: Workload name
21+
jsonPath: .spec.workloadName
22+
name: Workload
2323
type: string
24-
- description: Status of Deployment Reconciliation
25-
jsonPath: .status.deploymentStatus
24+
- description: Workload type
25+
jsonPath: .spec.workloadType
26+
name: Type
27+
type: string
28+
- description: Status of Workload Reconciliation
29+
jsonPath: .status.workloadStatus
2630
name: Status
2731
type: string
2832
- jsonPath: .metadata.creationTimestamp
@@ -86,7 +90,8 @@ spec:
8690
type: string
8791
type: array
8892
deploymentName:
89-
description: Name of the Deployment that will be patched
93+
description: Name of the Deployment that will be patched. Deprecated,
94+
use WorkloadName and WorkloadType instead
9095
type: string
9196
initContainer:
9297
properties:
@@ -115,11 +120,21 @@ spec:
115120
Lightrun server hostname that will be used for downloading an agent
116121
Key and company id in the secret has to be taken from this server as well
117122
type: string
123+
workloadName:
124+
description: Name of the Workload that will be patched. workload can
125+
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
126+
type: string
127+
workloadType:
128+
description: Type of the workload that will be patched supported values
129+
are Deployment, StatefulSet
130+
enum:
131+
- Deployment
132+
- StatefulSet
133+
type: string
118134
required:
119135
- agentEnvVarName
120136
- agentTags
121137
- containerSelector
122-
- deploymentName
123138
- initContainer
124139
- secretName
125140
- serverHostname
@@ -201,6 +216,8 @@ spec:
201216
lastScheduleTime:
202217
format: date-time
203218
type: string
219+
workloadStatus:
220+
type: string
204221
type: object
205222
type: object
206223
served: true

config/rbac/role.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ rules:
3939
- list
4040
- patch
4141
- watch
42+
- apiGroups:
43+
- apps
44+
resources:
45+
- statefulsets
46+
verbs:
47+
- get
48+
- list
49+
- patch
50+
- watch
4251
- apiGroups:
4352
- ""
4453
resources:

config/samples/agents_v1beta_lightrunjavaagent.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ 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+
workloadName: app
11+
workloadType: Deployment
1112
secretName: lightrun-secrets
1213
serverHostname: <lightrun_server> #for saas it will be app.lightrun.com
1314
agentEnvVarName: JAVA_TOOL_OPTIONS

config/samples/operator.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ spec:
2828
scope: Namespaced
2929
versions:
3030
- additionalPrinterColumns:
31-
- description: Deployment name
32-
jsonPath: .spec.deploymentName
33-
name: Deployment
31+
- description: Workload name
32+
jsonPath: .spec.workloadName
33+
name: Workload
3434
type: string
35-
- description: Status of Deployment Reconciliation
36-
jsonPath: .status.deploymentStatus
35+
- description: Workload type
36+
jsonPath: .spec.workloadType
37+
name: Type
38+
type: string
39+
- description: Status of Workload Reconciliation
40+
jsonPath: .status.workloadStatus
3741
name: Status
3842
type: string
3943
- jsonPath: .metadata.creationTimestamp
@@ -97,7 +101,8 @@ spec:
97101
type: string
98102
type: array
99103
deploymentName:
100-
description: Name of the Deployment that will be patched
104+
description: Name of the Deployment that will be patched. Deprecated,
105+
use WorkloadName and WorkloadType instead
101106
type: string
102107
initContainer:
103108
properties:
@@ -126,11 +131,21 @@ spec:
126131
Lightrun server hostname that will be used for downloading an agent
127132
Key and company id in the secret has to be taken from this server as well
128133
type: string
134+
workloadName:
135+
description: Name of the Workload that will be patched. workload can
136+
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
137+
type: string
138+
workloadType:
139+
description: Type of the workload that will be patched supported values
140+
are Deployment, StatefulSet
141+
enum:
142+
- Deployment
143+
- StatefulSet
144+
type: string
129145
required:
130146
- agentEnvVarName
131147
- agentTags
132148
- containerSelector
133-
- deploymentName
134149
- initContainer
135150
- secretName
136151
- serverHostname
@@ -212,6 +227,8 @@ spec:
212227
lastScheduleTime:
213228
format: date-time
214229
type: string
230+
workloadStatus:
231+
type: string
215232
type: object
216233
type: object
217234
served: true
@@ -315,6 +332,15 @@ rules:
315332
- list
316333
- patch
317334
- watch
335+
- apiGroups:
336+
- apps
337+
resources:
338+
- statefulsets
339+
verbs:
340+
- get
341+
- list
342+
- patch
343+
- watch
318344
- apiGroups:
319345
- ""
320346
resources:

0 commit comments

Comments
 (0)