Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Billing Reporter #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cosmic/microservices/cosmic-billing-reporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions cosmic/microservices/cosmic-billing-reporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: cosmic-billing-reporter
version: 0.1.0
icon: https://avatars1.githubusercontent.com/u/16591787
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "cosmic-billing-reporter.cosmic-billing-reporter.json" -}}
{
"spring": {
"application": {
"name": "cosmic-billing-reporter"
},
"cloud": {
"config": {
"uri": "http://cosmic-config-server:8080",
"token": {{ .Values.global.vault.readOnlyToken | quote }}
}
}
}
}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
namespace: {{ .Values.global.namespace }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ .Chart.Name }}
annotations:
pod.beta.kubernetes.io/init-containers: |
[{
"name": "config-server-health-checker",
"image": "python:alpine",
"command": ["/usr/local/bin/python"],
"args": [
"/scripts/readiness-probe.py",
"--host", "cosmic-config-server",
"--port", "8080",
"--path", "/health",
"--headers", "{\"X-Config-Token\": \"{{ .Values.global.vault.readOnlyToken }}\"}"
],
"imagePullPolicy": "IfNotPresent",
"volumeMounts": [{
"name": "init-container-scripts",
"mountPath": "/scripts",
"readOnly": true
}]
}]
spec:
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.global.registry }}{{ .Values.image.name }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: SPRING_APPLICATION_JSON
valueFrom:
secretKeyRef:
name: cosmic-billing-reporter
key: config
volumes:
- name: init-container-scripts
configMap:
name: init-container-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Chart.Name }}
namespace: {{ .Values.global.namespace }}
data:
config: {{ include "cosmic-billing-reporter.cosmic-billing-reporter.json" . | b64enc }}
14 changes: 14 additions & 0 deletions cosmic/microservices/cosmic-billing-reporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Default values for cosmic-metrics-collector.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
name: missioncriticalcloud/cosmic-billing-reporter
tag: latest
pullPolicy: IfNotPresent
service:

# Following values are required to have sane values
global:
vault:
readOnlyToken:
6 changes: 4 additions & 2 deletions custom/cosmic-vault/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ metadata:
data:
cosmic-bill-viewer.json: |
{{ include "cosmic-vault.cosmic-vault-files.cosmic-bill-viewer.json" . | indent 4 }}
cosmic-usage-api.json: |
{{ include "cosmic-vault.cosmic-vault-files.cosmic-usage-api.json" . | indent 4 }}
cosmic-billing-reporter.json: |
{{ include "cosmic-vault.cosmic-vault-files.cosmic-billing-reporter.json" . | indent 4 }}
cosmic-metrics-collector.json: |
{{ include "cosmic-vault.cosmic-vault-files.cosmic-metrics-collector.json" . | indent 4 }}
cosmic-usage-api.json: |
{{ include "cosmic-vault.cosmic-vault-files.cosmic-usage-api.json" . | indent 4 }}
init.sh: |
{{ include "cosmic-vault.cosmic-vault-files.init.sh" . | indent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- define "cosmic-vault.cosmic-vault-files.cosmic-billing-reporter.json" -}}
{
"spring": {
"datasource": {
"url": "jdbc:mariadb://192.168.22.61:3306/cloud",
"username": "cloud",
"password": "cloud",
"driver-class-name": "org.mariadb.jdbc.Driver"
},
"elasticsearch": {
"jest": {
"uris": "
{{- range $index, $node := .Values.global.elasticsearch.clusterNodes -}}
{{- if $index -}}
,
{{- end -}}
{{- $node -}}
{{- end -}}
"
}
},
"mail": {
"protocol": "smtp",
"host": {{ .Values.cosmic.billingReporter.mailHost | quote }},
"port": {{ .Values.cosmic.billingReporter.mailPort }},
"username": {{ .Values.cosmic.billingReporter.mailUsername | quote }},
"password": {{ .Values.cosmic.billingReporter.mailPassword | quote }}
},
"thymeleaf": {
"prefix": "classpath:/mail/html/"
}
},
"cosmic": {
"usage-core": {
"token-encryption-key": {{ .Values.cosmic.billingReporter.tokenEncryptionKey | quote }},
"token-encryption-salt": {{ .Values.cosmic.billingReporter.tokenEncryptionSalt | quote }}
},
"billing-reporter": {
"scan-interval": {{ .Values.cosmic.billingReporter.scanInterval | quote }},
"bill-viewer-base-url": {{ .Values.cosmic.billingReporter.billViewerBaseUrl | quote }},
"from-mail-address": {{ .Values.cosmic.billingReporter.fromEmailAddress | quote }},
"token-ttl": {{ .Values.cosmic.billingReporter.tokenTtl }}
}
}
}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"cosmic": {
"metrics-collector": {
"scan-interval": {{ .Values.cosmicScanInterval | quote }},
"scan-interval": {{ .Values.cosmic.metricsCollector.scanInterval | quote }},
"broker-exchange": "cosmic-metrics-exchange",
"broker-exchange-key": "cosmic-metrics-key"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
},
"cosmic": {
"usage-api": {
"scan-interval": {{ .Values.cosmicScanInterval | quote }}
"scan-interval": {{ .Values.cosmic.usageApi.scanInterval | quote }}
},
"usage-core": {
"token-encryption-key": {{ .Values.cosmicTokenEncryptionKey | quote }},
"token-encryption-salt": {{ .Values.cosmicTokenEncryptionSalt | quote }}
"token-encryption-key": {{ .Values.cosmic.usageApi.tokenEncryptionKey | quote }},
"token-encryption-salt": {{ .Values.cosmic.usageApi.tokenEncryptionSalt | quote }}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -x
until vault status; do sleep 1; done

vault write secret/cosmic-bill-viewer @/files/cosmic-bill-viewer.json
vault write secret/cosmic-billing-reporter @/files/cosmic-billing-reporter.json
vault write secret/cosmic-metrics-collector @/files/cosmic-metrics-collector.json
vault write secret/cosmic-usage-api @/files/cosmic-usage-api.json
{{- end -}}
20 changes: 17 additions & 3 deletions custom/cosmic-vault/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,24 @@ cosmic:
publicIpPrice: "1"
serviceFee: "5"
InnovationFee: "5"
billingReporter:
mailHost: "localhost"
mailPort: "25"
mailUsername: "admin"
mailPassword: "password"
tokenEncryptionKey: "D48F19E22D5E1BDA"
tokenEncryptionSalt: "5C0744940B5C369B"
scanInterval: "0 */15 * * * *"
billViewerBaseUrl: "http://localhost:7003/?token=%s&path=%s"
fromEmailAddress: "cosmic-billing-reporter@localhost"
tokenTtl: "3600000"
metricsCollector:
scanInterval: "0 */15 * * * *"
usageApi:
scanInterval: "0 */15 * * * *"
tokenEncryptionKey: "D48F19E22D5E1BDA"
tokenEncryptionSalt: "5C0744940B5C369B"

cosmicScanInterval: "0 */15 * * * *"
cosmicTokenEncryptionKey: "D48F19E22D5E1BDA"
cosmicTokenEncryptionSalt: "5C0744940B5C369B"
rootToken:

# Following values are required to have sane values
Expand Down