Skip to content

Commit

Permalink
Add Clowdapp.yml file for Entitlements (#112)
Browse files Browse the repository at this point in the history
* Push clowdapp.yml file for Entitlements Clowderization

* Update Cloudwatch to pull from clowder acgConfig

* remove optional dependencies from clowdapp.yaml

* Get app-common-go package

* Remove secret pulls that we don't need anymore
  • Loading branch information
aleccohan authored Apr 20, 2023
1 parent 14089f7 commit 46b1c6a
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"

"github.com/spf13/viper"

clowder "github.com/redhatinsights/app-common-go/pkg/api/v1"
)

var config *EntitlementsConfig
Expand Down Expand Up @@ -181,6 +183,17 @@ func initialize() {
RootCAs: getRootCAs(options.GetString(Keys.CaPath)),
Options: options,
}

if clowder.IsClowderEnabled() {
cfg := clowder.LoadedConfig

// Cloudwatch
options.Set(Keys.CwLogGroup, cfg.Logging.Cloudwatch.LogGroup)
options.Set(Keys.CwLogStream, cfg.Logging.Cloudwatch.LogGroup)
options.Set(Keys.CwRegion, cfg.Logging.Cloudwatch.Region)
options.Set(Keys.CwKey, cfg.Logging.Cloudwatch.AccessKeyId)
options.Set(Keys.CwSecret, cfg.Logging.Cloudwatch.SecretAccessKey)
}
}

// GetConfig provides a singleton global EntitlementsConfig instance
Expand Down
141 changes: 141 additions & 0 deletions deployment/clowdapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
---
apiVersion: v1
kind: Template
metadata:
name: entitlements-api-go
objects:
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: entitlements-api-go
spec:
envName: ${ENV_NAME}
deployments:
- name: service
webServices:
public:
enabled: True
minReplicas: ${{API_REPLICAS}}
podSpec:
initContainers:
- name: bundle-sync
image: quay.io/cloudservices/entitlements-api-go:${IMAGE_TAG}
command: ["/bundle-sync"]
env:
- name: ENT_SUBS_HOST
value: ${SUBS_HOST}
- name: ENT_BUNDLE_INFO_YAML
value: /bundles/bundles.yml
- name: ENT_CERTS_FROM_ENV
value: 'true'
- name: ENT_RUN_BUNDLE_SYNC
value: ${RUN_BUNDLE_SYNC}
envFrom:
- secretRef:
name: go-api-certs
volumeMounts:
- mountPath: /bundles
name: default-entitlements-config
inheritEnv: true
minReadySeconds: 15
progressDeadlineSeconds: 600
image: quay.io/cloudservices/entitlements-api-go:${IMAGE_TAG}
livenessProbe:
failureThreshold: 3
httpGet:
path: /status
port: 3000
initialDelaySeconds: 20
timeoutSeconds: 60
readinessProbe:
httpGet:
path: /status
port: 3000
initialDelaySeconds: 30
timeoutSeconds: 60
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 100m
memory: 250Mi
envFrom:
- secretRef:
name: go-api-certs
env:
- name: ENT_PORT
value: ${PORT}
- name: ENT_ENTITLE_ALL
value: ${ENTITLE_ALL}
- name: ENT_CERTS_FROM_ENV
value: 'true'
- name: ENT_CA_PATH
value: /resources/ca.crt
- name: ENT_SUBS_HOST
value: ${SUBS_HOST}
- name: ENT_COMPLIANCE_HOST
value: ${COMPLIANCE_HOST}
- name: ENT_OPENAPI_SPEC_PATH
value: /apispec/api.spec.json
- name: ENT_BUNDLE_INFO_YAML
value: /bundles/bundles.yml
- name: GLITCHTIP_DSN
valueFrom:
secretKeyRef:
name: ${GLITCHTIP_SECRET}
key: dsn
optional: true
- apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/port: '3000'
prometheus.io/scrape: 'true'
labels:
app: entitlements-api-go
name: entitlements-api-go
spec:
ports:
- name: 3000-tcp
port: 3000
protocol: TCP
targetPort: 8000
selector:
app: entitlements-service
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}

parameters:
- description: Port for listener
name: PORT
value: '8000'
- description: Subscriptions Service API endpoint
name: SUBS_HOST
value: https://subscription.qa.api.redhat.com
- description: Export Compliance Service API endpoint
name: COMPLIANCE_HOST
value: https://export-compliance.dev.api.redhat.com
- description: Name of the entitlements-config config map
name: CONFIG_MAP_NAME
value: entitlements-config
- description: The number of replicas to use in the deployment
name: REPLICAS
value: '1'
- description: Image tag
name: IMAGE_TAG
required: true
- description: Flag to determine whether or not to sync bundles on init
name: RUN_BUNDLE_SYNC
required: false
value: 'false'
- description: Flag to determine whether or not to entitle all by default and mock calls to IT
name: ENTITLE_ALL
required: false
value: 'false'
- description: The name of the Glitchtip secret
name: GLITCHTIP_SECRET
required: false
value: 'entitlements-secret'
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/redhatinsights/app-common-go v1.6.6 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/redhatinsights/app-common-go v1.6.6 h1:daOwCpGtW6IxGd9iO6TY3yoaV/HaHKjo/j/05dV0hHM=
github.com/redhatinsights/app-common-go v1.6.6/go.mod h1:6gzRyg8ZyejwMCksukeAhh2ZXOB3uHSmBsbP06fG2PQ=
github.com/redhatinsights/platform-go-middlewares v0.20.1-0.20230119152702-e3779317d1aa h1:noqA6UChsLTI+OQzWzzc+ASnAKb3RYlUfMHiJmY2rjM=
github.com/redhatinsights/platform-go-middlewares v0.20.1-0.20230119152702-e3779317d1aa/go.mod h1:i5gVDZJ/quCQhs5AW5CwkRPXlz1HfDBvyNtXHnlXZfM=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down

0 comments on commit 46b1c6a

Please sign in to comment.