Skip to content

Commit

Permalink
feat(csi metrics): enable csi sidecar metrics
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 7938

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin authored and derekbit committed Jul 23, 2024
1 parent 1b5cafd commit 7203805
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
28 changes: 28 additions & 0 deletions csi/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewAttacherDeployment(namespace, serviceAccount, attacherImage, rootDir str
"--leader-election-namespace=$(POD_NAMESPACE)",
fmt.Sprintf("--kube-api-qps=%v", types.KubeAPIQPS),
fmt.Sprintf("--kube-api-burst=%v", types.KubeAPIBurst),
fmt.Sprintf("--http-endpoint=:%v", types.CSISidecarMetricsPort),
},
int32(replicaCount),
tolerations,
Expand All @@ -78,6 +79,12 @@ func NewAttacherDeployment(namespace, serviceAccount, attacherImage, rootDir str
registrySecret,
imagePullPolicy,
nodeSelector,
[]corev1.ContainerPort{
{
Name: types.CSISidecarPortNameAttacher,
ContainerPort: types.CSISidecarMetricsPort,
},
},
)

return &AttacherDeployment{
Expand Down Expand Up @@ -119,6 +126,7 @@ func NewProvisionerDeployment(namespace, serviceAccount, provisionerImage, rootD
"--default-fstype=ext4",
fmt.Sprintf("--kube-api-qps=%v", types.KubeAPIQPS),
fmt.Sprintf("--kube-api-burst=%v", types.KubeAPIBurst),
fmt.Sprintf("--http-endpoint=:%v", types.CSISidecarMetricsPort),
},
int32(replicaCount),
tolerations,
Expand All @@ -127,6 +135,12 @@ func NewProvisionerDeployment(namespace, serviceAccount, provisionerImage, rootD
registrySecret,
imagePullPolicy,
nodeSelector,
[]corev1.ContainerPort{
{
Name: types.CSISidecarPortNameProvisioner,
ContainerPort: types.CSISidecarMetricsPort,
},
},
)

return &ProvisionerDeployment{
Expand Down Expand Up @@ -168,6 +182,7 @@ func NewResizerDeployment(namespace, serviceAccount, resizerImage, rootDir strin
"--leader-election-namespace=$(POD_NAMESPACE)",
fmt.Sprintf("--kube-api-qps=%v", types.KubeAPIQPS),
fmt.Sprintf("--kube-api-burst=%v", types.KubeAPIBurst),
fmt.Sprintf("--http-endpoint=:%v", types.CSISidecarMetricsPort),
// Issue: https://github.com/longhorn/longhorn/issues/3303
// TODO: Remove this after upgrading the CSI resizer version that contains the fix of https://github.com/kubernetes-csi/external-resizer/issues/175
"--handle-volume-inuse-error=false",
Expand All @@ -179,6 +194,12 @@ func NewResizerDeployment(namespace, serviceAccount, resizerImage, rootDir strin
registrySecret,
imagePullPolicy,
nodeSelector,
[]corev1.ContainerPort{
{
Name: types.CSISidecarPortNameResizer,
ContainerPort: types.CSISidecarMetricsPort,
},
},
)

return &ResizerDeployment{
Expand Down Expand Up @@ -219,6 +240,7 @@ func NewSnapshotterDeployment(namespace, serviceAccount, snapshotterImage, rootD
"--leader-election-namespace=$(POD_NAMESPACE)",
fmt.Sprintf("--kube-api-qps=%v", types.KubeAPIQPS),
fmt.Sprintf("--kube-api-burst=%v", types.KubeAPIBurst),
fmt.Sprintf("--http-endpoint=:%v", types.CSISidecarMetricsPort),
},
int32(replicaCount),
tolerations,
Expand All @@ -227,6 +249,12 @@ func NewSnapshotterDeployment(namespace, serviceAccount, snapshotterImage, rootD
registrySecret,
imagePullPolicy,
nodeSelector,
[]corev1.ContainerPort{
{
Name: types.CSISidecarPortNameSnapshotter,
ContainerPort: types.CSISidecarMetricsPort,
},
},
)

return &SnapshotterDeployment{
Expand Down
3 changes: 2 additions & 1 deletion csi/deployment_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
)

func getCommonDeployment(commonName, namespace, serviceAccount, image, rootDir string, args []string, replicaCount int32,
tolerations []corev1.Toleration, tolerationsString, priorityClass, registrySecret string, imagePullPolicy corev1.PullPolicy, nodeSelector map[string]string) *appsv1.Deployment {
tolerations []corev1.Toleration, tolerationsString, priorityClass, registrySecret string, imagePullPolicy corev1.PullPolicy, nodeSelector map[string]string, ports []corev1.ContainerPort) *appsv1.Deployment {

deploymentLabels := types.GetBaseLabelsForSystemManagedComponent()
deploymentLabels["app"] = commonName
Expand Down Expand Up @@ -91,6 +91,7 @@ func getCommonDeployment(commonName, namespace, serviceAccount, image, rootDir s
Image: image,
Args: args,
ImagePullPolicy: imagePullPolicy,
Ports: ports,
Env: []corev1.EnvVar{
{
Name: "ADDRESS",
Expand Down
6 changes: 6 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ const (

KubeAPIQPS = 50
KubeAPIBurst = 100

CSISidecarMetricsPort = 8000
CSISidecarPortNameAttacher = "csi-attacher"
CSISidecarPortNameProvisioner = "csi-provisioner"
CSISidecarPortNameResizer = "csi-resizer"
CSISidecarPortNameSnapshotter = "csi-snapshotter"
)

const (
Expand Down

0 comments on commit 7203805

Please sign in to comment.