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

aws_eks: add_manifest doesn't apply and always creates #32683

Open
1 task
idomic opened this issue Dec 29, 2024 · 2 comments
Open
1 task

aws_eks: add_manifest doesn't apply and always creates #32683

idomic opened this issue Dec 29, 2024 · 2 comments
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. effort/medium Medium work item – several days of effort p3 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@idomic
Copy link

idomic commented Dec 29, 2024

Describe the bug

We have this code to launch a router:

 # Virtual Service
        virtual_service_manifest = {
            "apiVersion": "appmesh.k8s.aws/v1beta2",
            "kind": "VirtualService",
            "metadata": {"name": "apps-router", "namespace": namespace},
            "spec": {
                "awsName": "apps-router.apps.svc.cluster.local",
                "provider": {
                    "virtualRouter": {"virtualRouterRef": {"name": "apps-router"}}
                },
            },
        }
        self.cluster.add_manifest(
            "VirtualService", virtual_service_manifest
        ).node.add_dependency(apps_namespace)

Whenever there's a new change in the stack it deletes all of the routes within the router, I assume it happens since cdk defaults to kubectl create instead of kubectl apply.
I also tried calling the typescript module directly with the overwrite parameter, which didn't seem to work as expected.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I expected it to apply the manifest so it detects no changes and move on without deleting the routes.

Current Behavior

The routes are being deleted on any change in the cdk stack regardless to that resource.

Reproduction Steps

Deploy this resource and add a new one to the stack, deploy again.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.163.1

Framework Version

No response

Node.js Version

v20.8.1

OS

Macos

Language

Python

Language Version

No response

Other information

No response

@idomic idomic added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Dec 29, 2024
@pahud pahud self-assigned this Dec 30, 2024
@pahud
Copy link
Contributor

pahud commented Dec 30, 2024

Hi

if request_type == 'Create':
# if "overwrite" is enabled, then we use "apply" for CREATE operations
# which technically means we can determine the desired state of an
# existing resource.
if overwrite:
kubectl('apply', manifest_file, *kubectl_opts)
else:
# --save-config will allow us to use "apply" later
kubectl_opts.extend(['--save-config'])
kubectl('create', manifest_file, *kubectl_opts)
elif request_type == 'Update':
if prune_label is not None:
kubectl_opts.extend(['--prune', '-l', prune_label])
kubectl('apply', manifest_file, *kubectl_opts)
elif request_type == "Delete":
try:
kubectl('delete', manifest_file)
except Exception as e:
logger.info("delete error: %s" % e)

kubectl by default uses "apply" when request_type == 'Update'

You can consider to follow this debugging tips and see the full kubectl command executed by lambda
#32187 (comment)
And run that command manually using kubectl from your terminal to validate its behavior.

@pahud pahud added the p3 label Dec 30, 2024
@pahud pahud removed their assignment Dec 30, 2024
@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 30, 2024
Copy link

github-actions bot commented Jan 1, 2025

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. effort/medium Medium work item – several days of effort p3 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants