Skip to content

Commit

Permalink
[COST-4417] Add service account support (#91)
Browse files Browse the repository at this point in the history
[COST-4417] Add service account support

* Make use of service account support in koku-nise v4.4.7
* remove the openshift directory from the containerfile
  • Loading branch information
chambridge authored Nov 9, 2023
1 parent 9cde984 commit d15b0bc
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 562 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ AZURE_STORAGE_CONNECTION_STRING=AZURE_STORAGE_CONNECTION_STRING
INSIGHTS_USER=INSIGHTS_USER
INSIGHTS_PASSWORD=INSIGHTS_PASSWORD
INSIGHTS_URL=INSIGHTS_URL
HCC_SERVICE_ACCOUNT_ID=HCC_SERVICE_ACCOUNT_ID
HCC_SERVICE_ACCOUNT_SECRET=HCC_SERVICE_ACCOUNT_SECRET

INSIGHTS_ACCOUNT_ID=INSIGHTS_ACCOUNT_ID
INSIGHTS_ORG_ID=INSIGHTS_ORG_ID
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ ENV \
PROMETHEUS_MULTIPROC_DIR=/tmp

# copy the src files into the workdir
COPY openshift openshift
COPY static-files static-files
COPY nise-populator nise-populator

Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ azure-storage-blob = "*"
oci = "*"

[dev-packages]
cython = "<3.0"

[requires]
python_version = "3.8"
633 changes: 345 additions & 288 deletions Pipfile.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ AZURE_STORAGE_CONNECTION_STRING=AZURE_STORAGE_CONNECTION_STRING
INSIGHTS_USER=INSIGHTS_USER
INSIGHTS_PASSWORD=INSIGHTS_PASSWORD
INSIGHTS_URL=INSIGHTS_URL
HCC_SERVICE_ACCOUNT_ID=HCC_SERVICE_ACCOUNT_ID
HCC_SERVICE_ACCOUNT_SECRET=HCC_SERVICE_ACCOUNT_SECRET


GCP_DATASET=GCP_DATASET
GCP_PROJECT_ID=GCP_PROJECT_ID
Expand Down
12 changes: 12 additions & 0 deletions deploy/clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ objects:
key: insights-password
name: ${SECRET_NAME}
optional: true
- name: HCC_SERVICE_ACCOUNT_ID
valueFrom:
secretKeyRef:
key: hcc-service-account-id
name: ${SECRET_NAME}
optional: true
- name: HCC_SERVICE_ACCOUNT_SECRET
valueFrom:
secretKeyRef:
key: hcc-service-account-secret
name: ${SECRET_NAME}
optional: true
- name: INSIGHTS_ACCOUNT_ID
valueFrom:
secretKeyRef:
Expand Down
11 changes: 10 additions & 1 deletion nise-populator/sources/ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def __init__(self, **kwargs):
self.insights_user = os.environ.get("INSIGHTS_USER")
self.insights_password = os.environ.get("INSIGHTS_PASSWORD")
self.insights_url = os.environ.get("INSIGHTS_URL")
self.hcc_service_account_id = os.environ.get("HCC_SERVICE_ACCOUNT_ID")
self.hcc_service_account_secret = os.environ.get(
"HCC_SERVICE_ACCOUNT_SECRET"
)
self.cluster_id = kwargs.get(self.CLUSTER_ID)
self.static_file = kwargs.get(self.STATIC_FILE)
super().__init__(**kwargs)
Expand All @@ -32,7 +36,12 @@ def get_source_type():

def check_configuration(self):
"""Determine if source is properly configured for access."""
if self.insights_user and self.insights_password and self.insights_url:
if self.insights_url and (
(self.insights_user and self.insights_password)
or (
self.hcc_service_account_id and self.hcc_service_account_secret
)
):
return True
return False

Expand Down
10 changes: 0 additions & 10 deletions openshift/example.parameters.properties

This file was deleted.

262 changes: 0 additions & 262 deletions openshift/nise-populator.yaml

This file was deleted.

0 comments on commit d15b0bc

Please sign in to comment.