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] document how to define dependencies between k8s resources #4291

Closed
lkoniecz opened this issue Sep 30, 2019 · 7 comments
Closed

[aws-eks] document how to define dependencies between k8s resources #4291

lkoniecz opened this issue Sep 30, 2019 · 7 comments
Assignees
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. p2

Comments

@lkoniecz
Copy link

lkoniecz commented Sep 30, 2019

Kubernetes resources are not deployed in the order they were added via add_resource method. If one of them is a namespace, for instance, others fail with a namespace not found error.

Reproduction Steps

eks_cluster = aws_eks.Cluster(..)
eks_cluster.add_resource('namespace', namespace_resource)
eks_cluster.add_resource('resource_1', resource_1_deployed_in_the_namespace)
..
eks_cluster.add_resource('resource_n', resource_n_deployed_in_the_namespace)

Error Log

  2/53 | 10:48:01 | CREATE_IN_PROGRESS   | Custom::AWSCDK-EKS-KubernetesResource | DevEksCluster/DevEksCluster/manifest-NginxRole/Resource/Default (DevEksClustermanifestNginxRoleEE01848C) Resource creation Initiated
  3/53 | 10:48:01 | CREATE_FAILED        | Custom::AWSCDK-EKS-KubernetesResource | DevEksCluster/DevEksCluster/manifest-NginxRole/Resource/Default (DevEksClustermanifestNginxRoleEE01848C) Failed to create resource. b'Error from server (NotFound): error when creating "/tmp/manifest.yaml": namespaces "ingress-nginx" not found\n'
	new CustomResource (/tmp/jsii-kernel-jIZKhq/node_modules/@aws-cdk/aws-cloudformation/lib/custom-resource.js:32:25)
	\_ new KubernetesResource (/tmp/jsii-kernel-jIZKhq/node_modules/@aws-cdk/aws-eks/lib/k8s-resource.js:22:9)
	\_ Cluster.addResource (/tmp/jsii-kernel-jIZKhq/node_modules/@aws-cdk/aws-eks/lib/cluster.js:215:16)
	\_ _wrapSandboxCode (/home/lky/Repositories/HuuugeStarsCfConfig/contrib/cloudformation/cdk/eks/cluster/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6498:51)
	\_ Kernel._wrapSandboxCode (/home/lky/Repositories/HuuugeStarsCfConfig/contrib/cloudformation/cdk/eks/cluster/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7131:20)
	\_ ret._ensureSync (/home/lky/Repositories/HuuugeStarsCfConfig/contrib/cloudformation/cdk/eks/cluster/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6498:25)
	\_ Kernel._ensureSync (/home/lky/Repositories/HuuugeStarsCfConfig/contrib/cloudformation/cdk/eks/cluster/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7102:20)

Environment

  • CLI Version :1.4.0
  • Framework Version:1.4.0
  • OS :all
  • Language :all

Other


This is 🐛 Bug Report

@lkoniecz lkoniecz added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 30, 2019
@SomayaB SomayaB added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Sep 30, 2019
@NGL321 NGL321 added needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 4, 2019
@lkoniecz
Copy link
Author

Can be fixed by adding cloudformation dependecies - https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.core.README.html#dependencies

to be closed

@eladb
Copy link
Contributor

eladb commented Oct 16, 2019

Yes, dependencies can be used to specify order between resources. We should add some example in the EKS module's README that demonstrates this.

@eladb eladb changed the title EKS add resources feature does not preserve any order eks: document how to define dependencies between k8s resources Oct 16, 2019
@eladb eladb removed the needs-reproduction This issue needs reproduction. label Oct 16, 2019
@eladb eladb added the p2 label Oct 23, 2019
@VinayRana5674
Copy link

Can anyone please help me, I have been trying this thing for 5 days. I have a custom resource in AWS YAML format, which I want to create in AWS CDK. I am able to add condition and ServiceToken using AWS CDK CfnCustomResource but I can't add properties. Please help me to find out the solution.

YAML Template

LookupAmi:
Condition: UseGI
Properties:
  ServiceToken:
      Fn::ImportValue: !Join ['', [!If [ MyProd, '', 'qa-'], Prod-LookupAmiFunction]]
  AMI: {Ref: AMI}      
  appId: {Ref: AppId}
  envType: {Ref: EnvType}
  osType: {Ref: OSType}
Type: Custom::AmiLookup

Corresponding AWS CDK typescript code which is working.

const LookupAmi = new cfn.CfnCustomResource(this, 'LookupAmi', {
  serviceToken : "DSDS"  # Just a random value but it is working



});LookupAmi.cfnOptions.condition = UseGI

I want to add properties of YAML template, how could I do it. Please help me........

@yjw113080
Copy link

@lkoniecz @eladb What if there's dependencies in the manifest yaml itself? As you already know, k8s itself recommend to have all the related objects in a yaml. So there's some case one manifest contains several objects with dependencies. For instance, cloudwatch agent's quickstart has namespace deployment as the very first step for its manifest. I wonder what you guys think of dealing with this.

@lkoniecz
Copy link
Author

@yjw113080 I found no other way than splitting the yaml into dependend pieces, in my case, namaspace into one file and all namespaced objects into the other.

@farshadniayeshpour
Copy link

Yes, dependencies can be used to specify order between resources. We should add some example in the EKS module's README that demonstrates this.

@eladb can you provide an example of how to do this? I am trying to create a dependency between namespace and helm chart.

@arjanschaaf
Copy link
Contributor

@FarshadNiayesh I ran into a similar situation and provided an example on how to create a dependency between two helm charts. But it would also work to provide a dependency between the namespace & chart: #7592 (comment)

@eladb eladb added this to the EKS Developer Preview milestone Jun 24, 2020
@eladb eladb changed the title eks: document how to define dependencies between k8s resources [EKS Feature]: document how to define dependencies between k8s resources Jun 24, 2020
@eladb eladb changed the title [EKS Feature]: document how to define dependencies between k8s resources [EKS Feature] document how to define dependencies between k8s resources Jun 24, 2020
@eladb eladb removed this from the EKS Developer Preview milestone Jun 24, 2020
@eladb eladb added this to the EKS Dev Preview milestone Jul 22, 2020
@eladb eladb closed this as completed Aug 4, 2020
@iliapolo iliapolo changed the title [EKS Feature] document how to define dependencies between k8s resources [aws-eks] document how to define dependencies between k8s resources Aug 16, 2020
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. p2
Projects
None yet
Development

No branches or pull requests

9 participants