-
Notifications
You must be signed in to change notification settings - Fork 17
Feat: Add --namespace
and --generate-namespace
flags for score-k8s generate
#176
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
Conversation
Hii @mathieu-benoit. I have made changes for the requested feature. I have added the test also and tested it locally. Could you please review the changes. If any modification required please let me know. |
Hey @Yadavanurag13, thank you for your PR, it looks wonderful! 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great, @Yadavanurag13, super neat, thanks!
Please go through the comments and suggestions from @7h3-3mp7y-m4n (thanks!), nothing critical, but small improvements needed.
Once taken into account, could you please add a new comment in this PR with the outputs of these 3 following commands to help for the final review?
score-k8s generate score.yaml --namespace=test-ns --generate-namespace
score-k8s generate score.yaml --namespace=test-ns
score-k8s generate score.yaml --generate-namespace
Thanks again!
Thanks @7h3-3mp7y-m4n @mathieu-benoit for the review. I'll incorporate all the required changes and let u know. |
Signed-off-by: Anurag Yadav <yadavanurag1310@gmail.com>
Signed-off-by: Anurag Yadav <yadavanurag1310@gmail.com>
Signed-off-by: Anurag Yadav <yadavanurag1310@gmail.com>
Signed-off-by: Anurag Yadav <yadavanurag1310@gmail.com>
--namespace
and --generate-namespace
flags for score-k8s generate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job here! Thanks, @Yadavanurag13!
I just did some tests with the associated binary, see below.
./score-k8s init
If doing ./score-k8s generate score.yaml
, no Namespace
manifests and no namespace
field in the generated Deployment
and Service
manifests.
If doing ./score-k8s generate score.yaml --namespace=test-ns --generate-namespace
, getting:
---
apiVersion: v1
kind: Namespace
metadata:
labels:
app.kubernetes.io/managed-by: score-k8s
name: test-ns
---
apiVersion: v1
kind: Service
metadata:
...
name: example
namespace: test-ns
...
---
apiVersion: apps/v1
kind: Deployment
metadata:
...
name: example
namespace: test-ns
If doing ./score-k8s generate score.yaml --namespace=test-ns
, getting:
---
apiVersion: v1
kind: Service
metadata:
...
name: example
namespace: test-ns
...
---
apiVersion: apps/v1
kind: Deployment
metadata:
...
name: example
namespace: test-ns
If doing ./score-k8s generate score.yaml --generate-namespace
, getting:
Error: --namespace flag is required when using --generate-namespace
If doing ./score-k8s generate --help
, getting:
The generate command will convert Score files in the current Score state into a combined set of Kubernetes
manifests. All resources and links between Workloads will be resolved and provisioned as required.
"score-k8s init" MUST be run first. An error will be thrown if the project directory is not present.
Usage:
score-k8s generate [flags]
Examples:
# Specify Score files
score-k8s generate score.yaml *.score.yaml
# Regenerate without adding new score files
score-k8s generate
# Provide a default container image for any containers with image=.
score-k8s generate score.yaml --image=nginx:latest
# Provide overrides when one score file is provided
score-k8s generate score.yaml --override-file=./overrides.score.yaml --override-property=metadata.key=value
# Patch resulting manifests
score-k8s generate score.yaml --patch-manifests */*/metadata.annotations.key=value --patch-manifests Deployment/foo/spec.replicas=4
# Set namespace for all resources
score-k8s generate score.yaml --namespace=test-ns
# Generate namespace manifest and set namespace for all resources
score-k8s generate score.yaml --namespace=test-ns --generate-namespace
Flags:
--generate-namespace If true, generate a namespace manifest. Requires --namespace to be set
-h, --help help for generate
--image string An optional container image to use for any container with image == '.'
--namespace string An optional namespace to set for all generated resources
-o, --output string The output manifests file to write the manifests to (default "manifests.yaml")
--override-property stringArray An optional set of path=key overrides to set or remove
--overrides-file string An optional file of Score overrides to merge in
--patch-manifests stringArray An optional set of <kind|*>/<name|*>/path=key operations for the output manifests
Global Flags:
--quiet Mute any logging output
-v, --verbose count Increase log verbosity and detail by specifying this flag one or more times
All good!
Description
This PR adds two new flags to the score-k8s generate command to support namespace management in generated Kubernetes manifests:
--namespace
: Sets the namespace for all generated resources--generate-namespace
: Creates a namespace manifest (requires--namespace
to be set)The implementation includes:
--generate-namespace
is only used with--namespace
--namespace
is used--generate-namespace
is usedWhat does this PR do?
This PR implements the feature request from issue #172 to add namespace management capabilities to the score-k8s generate command. It provides users with the ability to:
Types of changes
Checklist: