This repository has been archived by the owner on Dec 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Improve ES Sink: #1260
Merged
piosz
merged 5 commits into
kubernetes-retired:master
from
AlmogBaku:es_sink_improvments
Sep 2, 2016
Merged
Improve ES Sink: #1260
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df50dc0
Improve ES Sink:
AlmogBaku 9d05351
add missing files
AlmogBaku 97869bf
copyright notice in the file
AlmogBaku 8b28b5d
remove go-extpoints
AlmogBaku e6425d1
fixes logs msgs and verbosity levels (due to @huangyuqi review)
AlmogBaku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ eventer | |
*.un~ | ||
Session.vim | ||
.netrwhist | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2015 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package elasticsearch | ||
|
||
import ( | ||
"fmt" | ||
awsauth "github.com/smartystreets/go-aws-auth" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
type AWSSigningTransport struct { | ||
HTTPClient *http.Client | ||
Credentials awsauth.Credentials | ||
} | ||
|
||
// RoundTrip implementation | ||
func (a AWSSigningTransport) RoundTrip(req *http.Request) (*http.Response, error) { | ||
return a.HTTPClient.Do(awsauth.Sign4(req, a.Credentials)) | ||
} | ||
|
||
func createAWSClient() (*http.Client, error) { | ||
id := os.Getenv("AWS_ACCESS_KEY_ID") | ||
if id == "" { | ||
id = os.Getenv("AWS_ACCESS_KEY") | ||
} | ||
|
||
secret := os.Getenv("AWS_SECRET_ACCESS_KEY") | ||
if secret == "" { | ||
secret = os.Getenv("AWS_SECRET_KEY") | ||
} | ||
|
||
if id == "" || secret == "" { | ||
return nil, fmt.Errorf("Failed to configure AWS authentication. Both `AWS_ACCESS_KEY_ID` and " + | ||
"`AWS_SECRET_ACCESS_KEY` environment veriables required") | ||
} | ||
|
||
signingTransport := AWSSigningTransport{ | ||
Credentials: awsauth.Credentials{ | ||
AccessKeyID: id, | ||
SecretAccessKey: secret, | ||
}, | ||
HTTPClient: http.DefaultClient, | ||
} | ||
return &http.Client{Transport: http.RoundTripper(signingTransport)}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to deploy heapster, kubernetes or standalone?
And if using kubernetes to deploy, how to inject this environment variable?
Would you like to explain me the details of deployment?
Thanks so much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I personally recommend about deploying it into an external service rather than a k8s service to avoid a case of single-point-of-failure (especially when the ES used to help you track/resolving issues in the cluster...), but you can do both of course
Regarding the deployment, you can set the ENV by the k8s manifest.. for more details see what I wrote in the documentation of the ES Sink(https://github.com/AlmogBaku/heapster/blob/es_sink_improvments/docs/sink-configuration.md#aws)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, when deploying a pod in k8s, some authentication info can be read from
serviceaccout
(secret), equal to read from some files. I don't think putting secret information in deploy yaml file by ENVIRONMENT is a good way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to find some way to collect the AWS information from this secret, but couldn't find anything sufficient..
The only idea I had(for more secured access) is to do an HTTP request to AWS endpoint in order to get the temporary AWS token associated with an EC2's role.. however that's won't work in cases of a server that doesn't uses AWS(for federation cases for instance, or for using AWS as a secondary cloud sink). Also, this method will require maintaining some mechanism of leasing, and renewing from the AWS token's endpoint, inside the heapster(=very big feature).
Do you have a different idea how to store that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can refer to this link http://kubernetes.io/docs/user-guide/service-accounts/
with a conventional process, we can put these parameters like "AWS_ACCESS_KEY_ID" in secret, and use these by service-account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure what the difference between exposing it via ServiceAccount's secret, and a regular secret.. also I'm not sure how I access the ServiceAccount's secret.. via reading the file
/var/run/secrets/kubernetes.io/serviceaccount/aws_access_key
?*Also, these ENVs are the "common practice" by AWS GO SDK, I tried to align with them here(both with names and recommendations)
*The documentation of k8s for SA is pretty lack of info..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a controversial thing I'm ok with creating an issue and postponing the discussion there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue will not block this PR, so I think it is ready to be merged.
LGTM.
@piosz Please merge this.