-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto switch use iam-role/irsa when aws_access_key, aws_secret_key is …
…leaved null (#13) * options usage for iam role, irsa and add examples use with irsa * rename example k8s * example: update image * update function's name - get_aws_account_session_via_iam_user * change function default's name * update: boto3's behavior in exporter --------- Co-authored-by: phat.ntp <phat.ntp@xyz>
- Loading branch information
Showing
9 changed files
with
158 additions
and
9 deletions.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__ | ||
*.pyc | ||
.DS_Store | ||
.venv |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: aws-cost-exporter-config | ||
data: | ||
exporter_config.yaml: | | ||
exporter_port: $EXPORTER_PORT|9090 # the port that exposes cost metrics | ||
polling_interval_seconds: $POLLING_INTERVAL_SECONDS|28800 # by default it is 8 hours because for daily cost, AWS only updates the data once per day | ||
metric_name: aws_daily_cost_usd # change the metric name if needed | ||
aws_access_key: $AWS_ACCESS_KEY|"" # for prod deployment, DO NOT put the actual value here | ||
aws_access_secret: $AWS_ACCESS_SECRET|"" # for prod deployment, DO NOT put the actual value here | ||
aws_assumed_role_name: example-assumerole | ||
group_by: | ||
enabled: true | ||
# Cost data can be groupped using up to two different groups: DIMENSION, TAG, COST_CATEGORY. | ||
# ref: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetCostAndUsageWithResources.html | ||
# note: label_name should be unique, and different from the labes in target_aws_accounts | ||
groups: | ||
- type: DIMENSION | ||
key: SERVICE | ||
label_name: ServiceName | ||
- type: DIMENSION | ||
key: REGION | ||
label_name: RegionName | ||
merge_minor_cost: | ||
# if this is enabled, minor cost that is below the threshold will be merged into one group | ||
enabled: false | ||
threshold: 10 | ||
tag_value: other | ||
target_aws_accounts: | ||
# here defines a list of target AWS accounts | ||
# it should be guaranteed that all the AWS accounts have the same set of keys (in this example they are Publisher, ProjectName, and EnvironmentName) | ||
- Publisher: 234567890123 | ||
ProjectName: dev-team-1 | ||
EnvironmentName: dev | ||
- Publisher: 321645789123 | ||
ProjectName: dev-team-2 | ||
EnvironmentName: dev |
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,59 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: aws-cost-exporter | ||
labels: | ||
app.kubernetes.io/name: aws-cost-exporter | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: aws-cost-exporter | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: aws-cost-exporter | ||
spec: | ||
serviceAccount: aws-cost-exporter | ||
serviceAccountName: aws-cost-exporter | ||
containers: | ||
- name: aws-cost-exporter | ||
image: "opensourceelectrolux/aws-cost-exporter:v1.0.1" | ||
command: [ "python", "main.py", "-c", "/exporter_config.yaml" ] | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 9090 | ||
name: metrics | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: /health | ||
port: metrics | ||
failureThreshold: 10 | ||
initialDelaySeconds: 180 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
readinessProbe: | ||
httpGet: | ||
path: /health | ||
port: metrics | ||
failureThreshold: 10 | ||
initialDelaySeconds: 10 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
resources: | ||
limits: | ||
memory: 500Mi | ||
requests: | ||
cpu: 50m | ||
memory: 300Mi | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /exporter_config.yaml | ||
subPath: exporter_config.yaml | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: aws-cost-exporter-config |
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,7 @@ | ||
apiVersion: v1 | ||
automountServiceAccountToken: true | ||
kind: ServiceAccount | ||
metadata: | ||
annotations: | ||
eks.amazonaws.com/role-arn: arn:aws:iam::135468794354:role/aws-cost-exporter-irsa | ||
name: aws-cost-exporter |
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,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: aws-cost-exporter | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: metrics | ||
selector: | ||
app.kubernetes.io/name: aws-cost-exporter | ||
type: ClusterIP |
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 |
---|---|---|
|
@@ -73,4 +73,4 @@ spec: | |
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: aws-cost-exporter-config | ||
name: aws-cost-exporter-config |
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