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

Husam/use los csi #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Husam/use los csi #67

wants to merge 3 commits into from

Conversation

husam-lb
Copy link
Collaborator

@husam-lb husam-lb commented Dec 16, 2024

Add lb.yaml and Makefile.lb missing so this repo can be run with internal build tools.

Issue: LBM1-35810

Summary by CodeRabbit

  • New Features

    • Introduced a new Makefile for managing the build and installation of the lb-csi-plugin.
    • Added a structured configuration in lb.yaml for lb-csi-plugin and lb-csi-bundle, detailing build and installation commands.
  • Bug Fixes

    • Ensured the INSTALL_PATH is specified to avoid errors during the build process.

Signed-off-by: husam-lb <[email protected]>
Copy link

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces a comprehensive update to the build and deployment configuration for the lb-csi plugin. The changes primarily focus on enhancing the Makefile and configuration management, with new files and modifications that streamline the build, installation, and deployment processes. The updates include a new Makefile.lb for managing Docker and Helm chart builds, modifications to the main Makefile for Kubernetes manifest generation, and a new lb.yaml configuration file defining build and installation instructions for the plugin components.

Changes

File Change Summary
Makefile Added discoveryClientImage variable and Helm template commands for Kubernetes versions v1.17 to v1.30
Makefile.lb New Makefile with variables for Docker registry, Helm chart repository, build flags, and installation targets
lb.yaml New configuration file defining lb-csi-plugin and lb-csi-bundle components with build and installation commands

Poem

🐰 In the realm of code, a rabbit's delight,
Makefiles dancing, configs shining bright
Kubernetes manifests, now crystal clear
With discovery client images drawing near
Build, deploy, and conquer with glee! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 028c9e3 and 98abd45.

📒 Files selected for processing (2)
  • Makefile (14 hunks)
  • Makefile.lb (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Makefile
  • Makefile.lb

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@husam-lb husam-lb requested a review from davidf-lb December 16, 2024 08:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
Makefile (1)

Line range hint 150-385: Consider reducing duplication in Helm template commands.

The Helm template commands are repeated for each Kubernetes version with minimal differences. This could lead to maintenance issues.

Consider using a loop or function to generate templates:

KUBE_VERSIONS := v1.17 v1.18 v1.19 v1.20 v1.21 v1.22 v1.23 v1.24 v1.25 v1.26 v1.27 v1.28 v1.29 v1.30

define generate_helm_template
	helm template deploy/helm/lb-csi/ \
		--namespace=kube-system \
		--set allowExpandVolume=true \
		--set enableSnapshot=true \
		--set kubeVersion=$(1) \
		--set imageRegistry=$(DOCKER_REGISTRY) \
		--set sidecarImageRegistry=$(SIDECAR_DOCKER_REGISTRY) \
		--set image=$(DOCKER_TAG) > deploy/k8s/lb-csi-plugin-k8s-$(1).yaml
	helm template deploy/helm/lb-csi/ \
		--namespace=kube-system \
		--set allowExpandVolume=true \
		--set enableSnapshot=true \
		--set discoveryClientInContainer=true \
		--set kubeVersion=$(1) \
		--set imageRegistry=$(DOCKER_REGISTRY) \
		--set sidecarImageRegistry=$(SIDECAR_DOCKER_REGISTRY) \
		--set image=$(DOCKER_TAG) \
		--set discoveryClientImage=$(DISCOVERY_CLIENT_DOCKER_TAG) > deploy/k8s/lb-csi-plugin-k8s-$(1)-dc.yaml
endef

lb-csi-manifests: verify_image_registry deploy/k8s
	$(foreach ver,$(KUBE_VERSIONS),$(call generate_helm_template,$(ver)))
🧹 Nitpick comments (2)
lb.yaml (1)

9-20: Consider optimizing shared dependencies.

Both components share many common dependencies. Consider extracting common dependencies into a shared section to improve maintainability.

Example refactor:

 los-csi:
+  common_deps: &common_deps
+    - file://Makefile
+    - file://Makefile.lb
+    - file://main.go
+    - file://pkg
+    - file://go.mod
+    - file://go.sum
+    - file://VERSION
   lb-csi-plugin:
     build:
       - make -f Makefile.lb docker-build docker-bundle
     install:
       - make -f Makefile.lb install
     checkin:
       - make -f Makefile.lb checkin
     deps:
-      - file://Makefile
-      - file://Makefile.lb
-      - file://main.go
-      - file://pkg
+      <<: *common_deps
       - file://deploy/Dockerfile
       - file://Dockerfile.builder
       - file://deploy/licenses
-      - file://go.mod
-      - file://go.sum
-      - file://VERSION
       - file://lb.yaml
   lb-csi-bundle:
     build:
       - make -f Makefile.lb docker-bundle
     deps:
-      - file://Makefile
-      - file://Makefile.lb
-      - file://main.go
-      - file://pkg
+      <<: *common_deps
       - file://deploy
-      - file://go.mod
-      - file://go.sum
-      - file://VERSION

Also applies to: 24-32

Makefile.lb (1)

14-18: Enhance INSTALL_PATH validation.

The current validation only checks if INSTALL_PATH is empty. Consider adding additional validation for path safety.

 ifeq ($(INSTALL_PATH),"")
     $(error "lb-csi install path is not specified")
 endif
+ifeq ($(shell test -d $(dir $(INSTALL_PATH)) || echo invalid),invalid)
+    $(error "lb-csi install path parent directory does not exist")
+endif
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d41483 and 028c9e3.

📒 Files selected for processing (3)
  • Makefile (14 hunks)
  • Makefile.lb (1 hunks)
  • lb.yaml (1 hunks)
🔇 Additional comments (4)
lb.yaml (1)

1-32: LGTM! Clear and well-structured configuration.

The configuration is well-organized with clear separation of components and their respective build, installation, and dependency specifications.

Makefile.lb (1)

1-54: LGTM! Well-structured Makefile with clear target definitions.

The Makefile follows good practices:

  • Clear variable definitions with fallbacks
  • Proper use of override directives
  • Well-organized targets with dependencies
Makefile (2)

Line range hint 150-385: LGTM! Consistent integration of discovery client image.

The changes correctly integrate the discovery client image parameter across all Kubernetes versions.


Line range hint 150-385: Verify Kubernetes version compatibility range.

The manifest generation supports Kubernetes v1.17 through v1.30. Please verify if this range aligns with the CSI plugin's compatibility requirements.

✅ Verification successful

Based on the search results, I can generate the final response as we have sufficient information about the Kubernetes version compatibility:

Kubernetes version compatibility range is appropriate

The manifest generation for v1.17 through v1.30 aligns with the CSI plugin's compatibility requirements. The documentation confirms:

  • Minimum supported version is v1.16 and later for CSI volume expansion
  • Core deployment instructions cover Kubernetes v1.17 and above
  • Plugin is actively tested and maintained across these versions, with proper sidecar container versions for each Kubernetes release
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check CSI spec compatibility with Kubernetes versions

# Check CSI spec version in go.mod
rg -A 5 "k8s.io/csi-translation-lib" go.mod

# Check minimum supported Kubernetes version in documentation
rg -i "kubernetes.*version|version.*kubernetes" README.md docs/*

Length of output: 5452

Makefile.lb Outdated
Comment on lines 9 to 11
HELM_CHART_REPOSITORY := $(or $(HELM_CHART_REPOSITORY),http://helm-repo:8080)
HELM_CHART_REPOSITORY_USERNAME := $(or $(HELM_CHART_REPOSITORY_USERNAME),light)
HELM_CHART_REPOSITORY_PASSWORD := $(or $(HELM_CHART_REPOSITORY_PASSWORD),light)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider securing default credentials.

The default credentials for the Helm chart repository are hardcoded. This could pose a security risk if accidentally used in production.

Consider:

  1. Using environment variables without defaults
  2. Adding validation to ensure secure credentials are provided
-HELM_CHART_REPOSITORY_USERNAME := $(or $(HELM_CHART_REPOSITORY_USERNAME),light)
-HELM_CHART_REPOSITORY_PASSWORD := $(or $(HELM_CHART_REPOSITORY_PASSWORD),light)
+HELM_CHART_REPOSITORY_USERNAME := $(HELM_CHART_REPOSITORY_USERNAME)
+HELM_CHART_REPOSITORY_PASSWORD := $(HELM_CHART_REPOSITORY_PASSWORD)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
HELM_CHART_REPOSITORY := $(or $(HELM_CHART_REPOSITORY),http://helm-repo:8080)
HELM_CHART_REPOSITORY_USERNAME := $(or $(HELM_CHART_REPOSITORY_USERNAME),light)
HELM_CHART_REPOSITORY_PASSWORD := $(or $(HELM_CHART_REPOSITORY_PASSWORD),light)
HELM_CHART_REPOSITORY := $(or $(HELM_CHART_REPOSITORY),http://helm-repo:8080)
HELM_CHART_REPOSITORY_USERNAME := $(HELM_CHART_REPOSITORY_USERNAME)
HELM_CHART_REPOSITORY_PASSWORD := $(HELM_CHART_REPOSITORY_PASSWORD)

@davidf-lb
Copy link

@husam-lb From technical point of view about the changes you did, it looks good to me. However it seems to me that a review of someone that is familiar with the los-csi functionality and usage is required before merging the code into main tree. (@rahman-lb @yogev-lb )

@@ -147,7 +147,8 @@ lb-csi-manifests: verify_image_registry deploy/k8s
--set kubeVersion=v1.17 \
--set imageRegistry=$(DOCKER_REGISTRY) \
--set sidecarImageRegistry=$(SIDECAR_DOCKER_REGISTRY) \
--set image=$(DOCKER_TAG) > deploy/k8s/lb-csi-plugin-k8s-v1.17-dc.yaml
--set image=$(DOCKER_TAG) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you moving the tagging process done by the CI into this makefile ?

@@ -147,7 +147,8 @@ lb-csi-manifests: verify_image_registry deploy/k8s
--set kubeVersion=v1.17 \
--set imageRegistry=$(DOCKER_REGISTRY) \
--set sidecarImageRegistry=$(SIDECAR_DOCKER_REGISTRY) \
--set image=$(DOCKER_TAG) > deploy/k8s/lb-csi-plugin-k8s-v1.17-dc.yaml
--set image=$(DOCKER_TAG) \
--set discoveryClientImage=$(DISCOVERY_CLIENT_DOCKER_TAG) > deploy/k8s/lb-csi-plugin-k8s-v1.17-dc.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're adding more maintenance complexity to this already complex makefile.
How about if you this ?

The actual change is minimum from one version to the other and follows a strict order.
Move the subpart of deploy/k8s/lb-csi-plugin-k8s-v1.28.yaml and deploy/k8s/lb-csi-plugin-k8s-v1.28-dc.yaml [ k8s-v1.17 - k8s-v1.30 ] into a separate input file as input of versionList.

Repeat loop for helm template as many times you have entries in versionList. This will reduce all these repeated lines 133 - 385 to 7/8 lines.

e.g
helm template deploy/helm/lb-csi/
--namespace=kube-system
--set allowExpandVolume=true
--set enableSnapshot=true
--set discoveryClientInContainer=true
--set kubeVersion=version[i]
--set imageRegistry=$(DOCKER_REGISTRY)
--set sidecarImageRegistry=$(SIDECAR_DOCKER_REGISTRY)
--set image=$(DOCKER_TAG)
--set discoveryClientImage=$(DISCOVERY_CLIENT_DOCKER_TAG) > deploy/k8s/lb-csi-plugin-version[i] -dc.yaml

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know your thoughts .........

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think it's complicated but let's do this as part of another PR.

I think we don't need to support all the versions, we should support latest versions of k8s only.
Let's do this along with updating the containers.

@rahman-lb rahman-lb requested a review from ronen-lb December 19, 2024 00:08
rahman-lb
rahman-lb previously approved these changes Dec 20, 2024
@husam-lb husam-lb requested a review from rahman-lb December 21, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants