Skip to content

setting uri using service external IP #1005

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

Closed
oxeye-schmil opened this issue Oct 4, 2021 · 9 comments
Closed

setting uri using service external IP #1005

oxeye-schmil opened this issue Oct 4, 2021 · 9 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@oxeye-schmil
Copy link

oxeye-schmil commented Oct 4, 2021

Hi

According to https://aws.amazon.com/blogs/containers/integrate-amazon-api-gateway-with-amazon-eks/
we should aws cli to set the apigateway uri
In my helm chart I define a service that uses aws lb
I also define an apigateway and would like to use the service fqdn (erternal-ip) to set the uri
Any idea how to do it in the same chart?

service definition

kind: Service
metadata:
  name: {{.Release.Name}}-{{.Chart.Name}}-collector
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: external
    service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
spec:
  ports:
    - port: {{ .Values.collector.config.ports.http }}
      targetPort: {{ .Values.collector.config.ports.http }}
      protocol: TCP
  type: LoadBalancer
  selector:
    app: {{.Release.Name}}-{{.Chart.Name}}-collector

api gateway v2 definition

apiVersion: apigatewayv2.services.k8s.aws/v1alpha1
kind: API
metadata:
  name: saas-apigwv2-nlb
spec:
  body: '{
            "openapi": "3.0.1",
              "info": {
                "title": "saas-apigwv2-nlb",
                "version": "v1"
              },
              "paths": {
              "/\$default": {
                "x-amazon-apigateway-any-method" : {
                "isDefaultRoute" : true,
                "x-amazon-apigateway-integration" : {
                "payloadFormatVersion" : "1.0",
                "connectionId" : " {{ required "vpc ID required" .Values.apiGatewayV2.vpcID }} ",
                "type" : "http_proxy",
                "httpMethod" : "POST",
                "uri" : "$(aws elbv2 describe-listeners --load-balancer-arn $(aws elbv2 describe-load-balancers --region $AGW_AWS_REGION --query "LoadBalancers[?contains(DNSName, '$(kubectl get service authorservice -o jsonpath="{.status.loadBalancer.ingress[].hostname}")')].LoadBalancerArn" --output text) --region $AGW_AWS_REGION --query "Listeners[0].ListenerArn" --output text)",
                "connectionType" : "VPC_LINK"
                  }
                }
              },
              "components": {}
          }'
@oxeye-schmil oxeye-schmil added the kind/bug Categorizes issue or PR as related to a bug. label Oct 4, 2021
@RedbackThomson
Copy link
Contributor

Hey @oxeye-schmil,
This seems like an interesting proposition, and I can totally see value in a dynamic interaction between the two controllers. From what I understand, you would essentially like to inject the URI created by the ELB controller into the body of the APIGW API object within the same chart?

ACK controllers don't currently support something like that. I imagine this would be supported in the form of ConfigMap values, or something of that sort. For the moment, we expect that each spec field is statically defined, however. One suggestion I might make is that you install the ALB controller and your service annotations in one chart, and the ACK APIGWv2 controller and API in another chart. You can then set the body field of your API object from a Helm chart value, which can be modified at apply-time (eg. helm install --set body.uri=$(...) ...).

Hope that answers your question.

@oxeye-schmil
Copy link
Author

I did separate the charts for the moment
but it causes dependency between charts that causes devops issues
Can we tag it as a feature request?

@vijtrip2
Copy link
Contributor

vijtrip2 commented Oct 5, 2021

Hi @oxeye-schmil , Please correct me if my understanding below is incorrect.

You want to create a helm chart which has a k8s service(LoadBalancerType) and this k8s service's external IP will be used as uri in API resource.
The issue that you may be seeing are that API Gateway resource is not waiting for k8s service to be created and you'd like to have a dependency relation between them.

If above is correct, then we have a similar issue#545 that we will work on in the future to handle resource relationship.
But Note that resource relationship being handled there will be between different resources managed by same ACK controller. Ex: VpcId and API resource.

So I am not sure if we can take this up as a feature request to support relationship between resources not managed by same controller. And this is completely from a technical viewpoint because to establish relationship you need to add informers & watchers in controller.

@RedbackThomson
Copy link
Contributor

I will also point you to the following issues:
#20
#740

@oxeye-schmil
Copy link
Author

Hi

I have also another issue with creating an API and link it to a stage in the same Helm chart.
The stage resource requires the API ID
Is there a way to do it in a single helm chart?

Schmil

@RedbackThomson
Copy link
Contributor

The stage resource requires the API ID Is there a way to do it in a single helm chart?

Same as your initial question, we don't currently handle this use case. Fields in the spec need to be described statically at apply-time.

With that said, if you have an idea for how you would like this to be achieved - from a UX perspective - I would love to hear your feedback!

@oxeye-schmil
Copy link
Author

oxeye-schmil commented Oct 10, 2021

instead of using the aws api ID I would use the k8s API resource name.
In case the API name doesn't exist yet due to the order it was configured the controller should try again until it founds it.
State of the stage resource should be pending until it finds the API resource

By the way is possible to have the API resource run in "default" stage wihtout creating a stage resource?

@vijtrip2
Copy link
Contributor

By the way is possible to have the API resource run in "default" stage wihtout creating a stage resource?

No, you'll need to create the stage resource for invocation. It is possible to create the stage with name "$default", which will allow you to skip stage-name in invocation url.

@vijtrip2
Copy link
Contributor

We will take care of your feedback when implementing the above mentioned issues.
Please reopen if you have further questions/comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants