Skip to content

Conversation

@zmingxi
Copy link
Contributor

@zmingxi zmingxi commented Jun 1, 2023

What type of PR is this?
bug

Which issue does this PR fix:
#261

What does this PR do / Why do we need it:
This PR enables controller to take input from user

If an issue # is not available please add repro steps and logs from aws-gateway-controller showing the issue:

Testing done on this change:
make e2etest
unit test
helm install --set awsRegion=us-west-2 --set awsAccountId=123456789 --set clusterVpcId=vpc-12345678 --dry-run --debug helm --generate-name
conformance test

Automation added to e2e:
N/A

Will this PR introduce any new dependencies?:
No

Will this break upgrades or downgrades. Has updating a running cluster been tested?:
No
Does this PR introduce any user-facing change?:
No

 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@zmingxi zmingxi requested a review from liwenwu-amazon June 1, 2023 20:07
@coveralls
Copy link

coveralls commented Jun 1, 2023

Pull Request Test Coverage Report for Build 5148739696

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 31.963%

Totals Coverage Status
Change from base Build 5147188293: 0.0%
Covered Lines: 3195
Relevant Lines: 9996

💛 - Coveralls

func ConfigInit() {
// discover VPC using environment first
VpcID = os.Getenv("CLUSTER_VPC_ID")
Copy link
Contributor

@liwenwu-amazon liwenwu-amazon Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to change this? Today we documented how to use these environments variables and they are used for developers as well (e..g make presubmit)

Copy link
Contributor Author

@zmingxi zmingxi Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document says: When running AWS Gateway API Controller outside the Kubernetes Cluster, this specify the VPC of the cluster.

This code changes is to take the input while running AWS Gateway API Controller inside the Kubernetes Cluster.

@zmingxi zmingxi requested a review from solmonk June 1, 2023 22:36
} else {
VpcID = os.Getenv("CLUSTER_VPC_ID")
glog.V(2).Infoln("CLUSTER_VPC_ID from local dev environment: ", VpcID)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I have seen, the most common practice on config is to have priority order flag > env > auto-resolve. I think env variable should be a way of configuring things regardless of dev environment. This way we can simply set env var as a default value of a flag, and run discovery if the current value is empty.

Actually... we have a lot of configuration variables (longname mode for example) and I think they all should be configurable by both flag and env. It makes things bigger so we can leave it to other task though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have two ways of configuring the same value I think the naming should be consistent

e.g. flag aws-vpc-id -> env AWS_VPC_ID

Copy link
Contributor Author

@zmingxi zmingxi Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I discussed with Liwen, we plan to go with env, no flag for now. I am going to change this using env var.

{{ if .Values.deployment.priorityClassName -}}
priorityClassName: {{ .Values.deployment.priorityClassName }}
{{ end -}}
{{- if .aws.region }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be somewhere inside like args block?

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5150455119

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 31.963%

Totals Coverage Status
Change from base Build 5147188293: 0.0%
Covered Lines: 3195
Relevant Lines: 9996

💛 - Coveralls
kubectl apply -f config/crds/bases/k8s-gateway-v0.6.1.yaml
kubectl apply -f config/crds/bases/multicluster.x-k8s.io_serviceexports.yaml
kubectl apply -f config/crds/bases/multicluster.x-k8s.io_serviceimports.yaml
kubectl apply -f examples/gatewayclass.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do u delete this?

Comment on lines 38 to 37
You should set up the correct `REGION` env variable and create `non-default`
namespace if it doesn't exist.

NOTE: You'll need to allow in-bound traffics from lattice prefix list in the security
groups of your cluster.

```bash
# create non-default namespace if it hasn't existed yet
kubectl create namespace non-default

You should set up the correct `REGION` env variable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do u delete all these?

Copy link
Contributor Author

@zmingxi zmingxi Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt intent to delete this, i need to fetch new code change.

make build-deploy
```
Then follow [Deploying the AWS Gateway API Controller](https://github.com/aws/aws-application-networking-k8s/blob/main/docs/deploy.md) to configure and deploy the docker image
Then follow [Deploying the AWS Gateway API Controller](https://github.com/aws/aws-application-networking-k8s/blob/main/docs/deploy.md) to configure and deploy the docker image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all these white-space diff

@liwenwu-amazon
Copy link
Contributor

Please also add or modify unit test for the change

@coveralls
Copy link

coveralls commented Jun 2, 2023

Pull Request Test Coverage Report for Build 5159899025

  • 36 of 39 (92.31%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 32.439%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/config/controller_config.go 36 39 92.31%
Totals Coverage Status
Change from base Build 5147188293: 0.5%
Covered Lines: 3275
Relevant Lines: 10096

💛 - Coveralls
docs/deploy.md Outdated
--version=v0.0.12 \
--set=aws.region=$AWS_REGION --set=serviceAccount.create=false --namespace aws-application-networking-system
--set=serviceAccount.create=false --namespace aws-application-networking-system \
# Region, clusterVpcId, awsAccountId are required for fargate use case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you replace "fargate use case" to something " for the case where IMDS are not available for discovering Region, clusterVpcId, awsAccountId, for example fargate usecase"

var VpcID = "vpc-xxxx"
var AccountID = "yyyyyy"
var Region = "us-west-2"
var VpcID = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT,can use use a constant for ""? e.g. UNKNOWN_VPCID=""


// VpcId
VpcID = os.Getenv("CLUSTER_VPC_ID")
if VpcID != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT, use constant instead of ""

)

// TODO endpoint, region
var VpcID = "vpc-xxxx"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u also remove //TODO comment? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants