Skip to content
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

feat(csi metrics): enable csi sidecar metrics #2978

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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