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

fix: create a common chart per deployment if needed #191

Merged
merged 27 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
719af57
fix: create a unique prometheus chart per deployment
Jorg88 Feb 14, 2025
e03ab90
Fix the unit tests
Jorg88 Feb 14, 2025
60d7790
fix: create a service chart per deployment
Jorg88 Feb 14, 2025
77b1ef6
chore: remove imagePullSecrets and generate sealed secrets per deploy…
Jorg88 Feb 19, 2025
dc5d9a2
Fix the sealed secrets unit tests
Jorg88 Feb 19, 2025
92cfc48
Use pr version docker image for testing purposes
Jorg88 Feb 19, 2025
cdc997c
Merge branch 'main' of github.com:Vandebron/gh-mpyl into feature/GUIL…
Jorg88 Feb 19, 2025
f43448a
chore: add labels per deployment when needed
Jorg88 Feb 19, 2025
f06dbbe
Fix the env var namespace replacement to account for multiple deploym…
Jorg88 Feb 19, 2025
be8093a
Merge branch 'main' of github.com:Vandebron/gh-mpyl into feature/GUIL…
Jorg88 Feb 19, 2025
f63e738
Only update the the env var if it's changed
Jorg88 Feb 19, 2025
b7ec2d0
Use the lower case deployment name for deployments, sealed secrets an…
Jorg88 Feb 19, 2025
9f7e26c
Also lower case the service name
Jorg88 Feb 19, 2025
e3ef2c4
Also change the name of the sealed secrets key ref
Jorg88 Feb 19, 2025
30a2183
Only add the vandebron.nl/deployment label to service charts
Jorg88 Feb 20, 2025
43bc80f
Fix deployment chart tests
Jorg88 Feb 20, 2025
a756e88
chore: use the deployment name for the ingress route and middlewaress
Jorg88 Feb 20, 2025
8eb8d9c
Merge branch 'main' of github.com:Vandebron/gh-mpyl into feature/GUIL…
Jorg88 Feb 20, 2025
4d1b820
Make sure resources have unique names in non pr namespaces
Jorg88 Feb 26, 2025
5538967
Merge branch 'main' of github.com:Vandebron/gh-mpyl into feature/GUIL…
Jorg88 Feb 27, 2025
0f2b9b1
Use the new name for the sealed secret refs
Jorg88 Feb 27, 2025
0f8f68d
Also update the unit tests
Jorg88 Feb 27, 2025
6a993d6
replace SERVICE-NAME with the actual project name during traefik char…
ptab Feb 27, 2025
4e3b09b
include the service name in the hostwrapper name to fix all reference…
ptab Feb 27, 2025
f71eb2c
aligned the filename for the generated whitelist
ptab Feb 27, 2025
efdcf1c
added the vandebron.nl/deployment label to every resource that is own…
ptab Feb 27, 2025
7baecf3
aligned all middleware names
ptab Feb 28, 2025
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
2 changes: 1 addition & 1 deletion actions/discover-run-plan/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
required: false
runs:
using: docker
image: docker://public.ecr.aws/vdb-public/gh-mpyl:v1.2.2
image: docker://public.ecr.aws/vdb-public/gh-mpyl:pr-191
args:
- plan
- discover
Expand Down
2 changes: 1 addition & 1 deletion actions/generate-kubernetes-manifests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ inputs:
required: false
runs:
using: docker
image: docker://public.ecr.aws/vdb-public/gh-mpyl:v1.2.2
image: docker://public.ecr.aws/vdb-public/gh-mpyl:pr-191
args:
- build
- --environment
Expand Down
2 changes: 1 addition & 1 deletion actions/health-check/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
required: false
runs:
using: docker
image: docker://public.ecr.aws/vdb-public/gh-mpyl:v1.2.2
image: docker://public.ecr.aws/vdb-public/gh-mpyl:pr-191
args:
- health
env:
Expand Down
2 changes: 1 addition & 1 deletion actions/lint-projects/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
required: false
runs:
using: docker
image: docker://public.ecr.aws/vdb-public/gh-mpyl:v1.2.2
image: docker://public.ecr.aws/vdb-public/gh-mpyl:pr-191
args:
- projects
- lint
Expand Down
2 changes: 0 additions & 2 deletions mpyl_config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ project: # default values
allowedMaintainers: [Team1, Team2, MPyL]
deployment:
kubernetes:
imagePullSecrets:
- name: acme-registry
job:
ttlSecondsAfterFinished:
all: 3600
Expand Down
6 changes: 2 additions & 4 deletions src/mpyl/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ class Kubernetes:
metrics: Optional[Metrics]
resources: Resources
job: Optional[Job]
image_pull_secrets: dict
role: Optional[dict]
command: Optional[TargetProperty[str]]
args: Optional[TargetProperty[str]]
Expand All @@ -332,7 +331,6 @@ def from_config(values: dict):
metrics=Metrics.from_config(values.get("metrics", {})),
resources=Resources.from_config(values.get("resources", {})),
job=Job.from_config(values.get("job", {})),
image_pull_secrets=values.get("imagePullSecrets", {}),
role=values.get("role"),
command=TargetProperty.from_config(values.get("command", {})),
args=TargetProperty.from_config(values.get("args", {})),
Expand Down Expand Up @@ -548,8 +546,8 @@ def project_overrides_yaml_file_pattern() -> str:
return "project-override-*.yml"

@staticmethod
def traefik_yaml_file_name(service_name: str) -> str:
return f"{service_name}-traefik.yml"
def traefik_yaml_file_name(deployment_name: str) -> str:
return f"{deployment_name}-traefik.yml"

@property
def root_path(self) -> Path:
Expand Down
6 changes: 0 additions & 6 deletions src/mpyl/schema/project.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,6 @@ definitions:
additionalProperties: false
portMappings:
type: object
imagePullSecrets:
minItems: 1
description: 'ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling any images in pods that reference this ServiceAccount. ImagePullSecrets are distinct from Secrets because Secrets can be mounted in the pod, but ImagePullSecrets are only accessed by the kubelet. More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod'
items:
$ref: k8s_api_core.schema.yml#/definitions/io.k8s.api.core.v1.LocalObjectReference
type: [array, null]
job:
type: object
additionalProperties: true
Expand Down
30 changes: 22 additions & 8 deletions src/mpyl/steps/deploy/k8s/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,32 @@ def get_namespace_for_linked_project(project: Project) -> str:
return f"pr-{pr_identifier}"
return project.namespace(target)

def replace_namespace(env_value: str, project_name: str, namespace: str) -> str:
search_value = project_name + ".{namespace}"
replace_value = project_name + "." + namespace
return env_value.replace(search_value, replace_value)
def replace_namespace(
original_value: str,
service_name: str,
namespace: str,
):
search_value = service_name + ".{namespace}"
replace_value = service_name + "." + namespace
replaced_namespace = original_value.replace(search_value, replace_value)
updated_pr = replace_pr_number(replaced_namespace, pr_identifier)
if updated_pr != original_value:
env[key] = updated_pr

for project in all_projects:
linked_project_namespace = get_namespace_for_linked_project(project)
for key, value in env.items():
replaced_namespace = replace_namespace(
value, project.name, linked_project_namespace
replace_namespace(
original_value=value,
service_name=project.name,
namespace=linked_project_namespace,
)
updated_pr = replace_pr_number(replaced_namespace, pr_identifier)
env[key] = updated_pr

for deployment in project.deployments:
replace_namespace(
original_value=value,
service_name=deployment.name,
namespace=linked_project_namespace,
)

return env
Loading
Loading