add AWS SQS event source#328
Conversation
|
/assign @scothis |
ba2e056 to
636b2e4
Compare
|
/assign @n3wscott |
n3wscott
left a comment
There was a problem hiding this comment.
Will look again when not WIP
| } | ||
|
|
||
| func NewAWSSQSEventSource(kubeclientset kubernetes.Interface, feedNamespace string, feedServiceAccountName string, image string) sources.EventSource { | ||
| glog.Infof("Image: %q", image) |
There was a problem hiding this comment.
Note we have been moving away from glog. We are moving to either zap for controller logging and log for jobs logging.
|
|
||
| err := a.deleteAWSSQSDeployment(deploymentName) | ||
| if err != nil { | ||
| glog.Warningf("Failed to delete deployment: %s", err) |
| glog.Infof("creating awssqs feed context") | ||
| // create aws sqs deployment | ||
| awsToken := "" | ||
| awsId := trigger.Parameters["AWS_ACCESS_KEY_ID"].(string) |
There was a problem hiding this comment.
magic keys should be moved to a string const block at top.
| awsToken := "" | ||
| awsId := trigger.Parameters["AWS_ACCESS_KEY_ID"].(string) | ||
| awsKey := trigger.Parameters["AWS_SECRET_ACCESS_KEY"].(string) | ||
| if token, ok := trigger.Parameters["AWS_SESSION_TOKEN"].(string); ok { |
There was a problem hiding this comment.
I would assign awsToken directly and then ...; !ok || len(awsToken) == 0 {
I have a few examples of pulling params out of contexts and objects here: https://github.com/knative/eventing/pull/276/files#diff-15c4ba004c85a3abc13efbe47a731b58R391
| if len(resource) != 2 { | ||
| return nil, fmt.Errorf("invalid resource: must be region/queue-name") | ||
| } | ||
| region := resource[0] |
There was a problem hiding this comment.
| if err != nil { | ||
| return nil, err | ||
| } | ||
| deploymentName := "awssqs-" + queueName + "-" + uuid.String() |
There was a problem hiding this comment.
uuid is a very large number. Paul had a better method by using k8s generate name. @pmorie can you link to that api to get the short random name?
| var p parameters | ||
| err := json.Unmarshal(decodedParameters, &p) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("can not unmarshal %q : %v", decodedParameters, err)) |
There was a problem hiding this comment.
I moved from panic to os.Exit(0) with a log above
| resource: us-east-1/knative-demo | ||
| service: aws-sqs | ||
| parametersFrom: | ||
| - secretKeyRef: |
There was a problem hiding this comment.
Should consider the case that cluster is running on AWS, and use KIAM to do IAM role delegation. This is how people access AWS resources from a k8s cluster running on EC2 instances without using any credentials.
The implementation can support both cases, with credential, or KIAM delegated Role. For the latter case, the IAM role configuration would be like:
-
Kubernetes cluster master nodes IAM role (This should already be existing after the cluster is created), this role should have the policy to assume-role
-
An IAM role which is assigned to a namespace (and will be used by the POD), this role is set to trust cluster master node IAM role, with KIAM, your pod can get temp credential to this IAM role by calling AWS metadata API, without using any credential. This Role also needs the policy to assume-role.
-
A third role to be able to operate SQS, and it trusts the 2nd IAM role.
-
In flow configuration, the 2nd and 3rd IAM role ARNs are needed, so that in your receive_adaptor you can use the 2nd role credential to assume 3rd role, and then read messages.
There was a problem hiding this comment.
I didn't see this PR until this afternoon. Before that, I implemented a SQS event source about 1 week ago, which was very similar to this. The major difference is, my k8s cluster is running on EC2 instances, and I use KIAM, so I don't use any explicit credentials to access AWS SQS. So I gave above comments, it would be better if this case can be considered in the PR.
|
@whynowy thanks, i ran my tests locally, IAM is a good idea, I'll get this here after eventing core is settled. |
Signed-off-by: Huamin Chen <hchen@redhat.com>
Signed-off-by: Huamin Chen <hchen@redhat.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rootfs If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@rootfs: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
Fixes #
Proposed Changes