Skip to content

Commit

Permalink
update Tiltfile and kardinal manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Sep 23, 2024
1 parent e00a1d3 commit 65b5ade
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
uses: DeterminateSystems/flake-checker-action@main
with:
fail-mode: true
check-outdated: false

# Nix-specific logic begins here
- name: Nix Check
Expand Down
22 changes: 16 additions & 6 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
FRONTEND_SERVICE_NAME='frontend'
CARTSERVICE_SERVICE_NAME='cartservice'
PRODUCTCATALOG_SERVICE_NAME='productcatalogservice'
METRICS_SERVICE_NAME='metrics'
DEV_IMAGE_SUFFIX='-dev-image'
FRONTEND_REF=FRONTEND_SERVICE_NAME + DEV_IMAGE_SUFFIX
CARTSERVICE_REF=CARTSERVICE_SERVICE_NAME + DEV_IMAGE_SUFFIX
PRODUCTCATALOG_REF=PRODUCTCATALOG_SERVICE_NAME + DEV_IMAGE_SUFFIX
METRICS_REF=METRICS_SERVICE_NAME + DEV_IMAGE_SUFFIX

# enforces a minimum Tilt version
version_settings(constraint='>=0.22.2')
Expand All @@ -26,7 +28,7 @@ if 'build' in arguments:
build_arg_len = len(build_arg)

# validate the 'build' argument
valid_build_arguments = [FRONTEND_SERVICE_NAME, CARTSERVICE_SERVICE_NAME, PRODUCTCATALOG_SERVICE_NAME]
valid_build_arguments = [FRONTEND_SERVICE_NAME, CARTSERVICE_SERVICE_NAME, PRODUCTCATALOG_SERVICE_NAME, METRICS_SERVICE_NAME]
for bu_arg in build_arg:
if bu_arg not in valid_build_arguments:
fail('build argument {} is not valid. Valid arguments are: {}'.format(bu_arg, valid_build_arguments))
Expand All @@ -40,7 +42,7 @@ if k8s_context() == 'minikube':
local('eval $(minikube docker-env)')

# set the env var to use the local Kontrol
local('export KARDINAL_CLI_DEV_MODE=TRUE')
os.environ["KARDINAL_CLI_DEV_MODE"] = "TRUE"

# clean current flows before creating new ones, it's just for the tilt up cmd
if config.tilt_subcommand == 'up':
Expand Down Expand Up @@ -70,16 +72,16 @@ if config.tilt_subcommand == 'up':
if 'cartservice' in build_arg:
docker_build(
CARTSERVICE_REF,
context='./src/cartservice',
dockerfile='./src/cartservice/Dockerfile',
context='./src',
dockerfile='./src/cartservice.dockerfile',
)

# PRODUCT CATALOG SERVICE
if 'productcatalogservice' in build_arg:
docker_build(
PRODUCTCATALOG_REF,
context='./src/productcatalogservice',
dockerfile='./src/productcatalogservice/Dockerfile',
context='./src',
dockerfile='./src/productcatalogservice.dockerfile',
)

# FRONTEND
Expand All @@ -90,6 +92,14 @@ if 'frontend' in build_arg:
dockerfile='./src/frontend.dockerfile',
)

# METRICS
if 'metrics' in build_arg:
docker_build(
METRICS_REF,
context='./src',
dockerfile='./src/metrics.dockerfile',
)

kardinal_topology_yaml = local(['kardinal', 'topology', 'print-manifest', '--add-trace-router'], quiet=True)
kardinal_topology_yaml_str = str(kardinal_topology_yaml)

Expand Down
89 changes: 85 additions & 4 deletions release/obd-kardinal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,22 @@ spec:
- name: "Cookie"
value: "shop_session-id=x-liveness-probe"
env:
- name: ADDRESS
value: ":8080"
- name: JSDELIVRAPIKEY
value: "prod"
- name: CARTSERVICEHOST
value: cartservice
- name: PRODUCTCATALOGSERVICEHOST
value: productcatalogservice
#- name: AWS_REGION
# value: us-east-1
#- name: AWS_ACCESS_KEY_ID
# value:
#- name: AWS_SECRET_ACCESS_KEY
# value:
#- name: QUEUE_URL
# value:
#- name: SNS_TOPIC_ARN
# value:
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -170,7 +178,7 @@ metadata:
name: frontend-external
annotations:
kardinal.dev.service/ingress: "true"
kardinal.dev.service/host: "prod.app.localhost"
kardinal.dev.service/host: "baseline.app.localhost"
spec:
type: LoadBalancer
selector:
Expand Down Expand Up @@ -331,4 +339,77 @@ spec:
port: 8070
targetPort: 8070
protocol: TCP
appProtocol: HTTP
appProtocol: HTTP

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-v1
labels:
app: metrics
version: v1
spec:
selector:
matchLabels:
app: metrics
version: v1
template:
metadata:
labels:
app: metrics
version: v1
annotations:
sidecar.istio.io/rewriteAppHTTPProbers: "true"
spec:
containers:
- name: server
image: kurtosistech/metrics:main
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8091
readinessProbe:
initialDelaySeconds: 10
httpGet:
path: "/_healthz"
port: 8091
httpHeaders:
- name: "Cookie"
value: "shop_session-id=x-readiness-probe"
livenessProbe:
initialDelaySeconds: 10
httpGet:
path: "/_healthz"
port: 8091
httpHeaders:
- name: "Cookie"
value: "shop_session-id=x-liveness-probe"
#env:
#- name: AWS_REGION
# value: us-east-1
#- name: AWS_ACCESS_KEY_ID
# value:
#- name: AWS_SECRET_ACCESS_KEY
# value:
#- name: QUEUE_URL
# value:
#- name: SNS_TOPIC_ARN
# value:
---
apiVersion: v1
kind: Service
metadata:
name: metrics
labels:
app: metrics
version: v1
spec:
type: ClusterIP
selector:
app: metrics
ports:
- name: http
port: 8091
protocol: TCP
appProtocol: HTTP
targetPort: 8091
9 changes: 4 additions & 5 deletions src/libraries/events/eventsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ func newEventsManager(snsTopicARN string, queueUrl string) *EventsManager {

func CreateEventsManager() (*EventsManager, error) {

//awsKey := os.Getenv("AWS_ACCESS_KEY_ID")
//awsSecret := os.Getenv("AWS_SECRET_ACCESS_KEY")
awsKey := os.Getenv("AWS_ACCESS_KEY_ID")
awsSecret := os.Getenv("AWS_SECRET_ACCESS_KEY")
awsRegion := os.Getenv("AWS_REGION")

if awsRegion == "" {
//return nil, errors.New("imposible to init the events manager component because the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY or AWS_REGION environment variable not set")
return nil, errors.New("imposible to init the events manager component because AWS_REGION environment variable not set")
if awsRegion == "" || awsKey == "" || awsSecret == "" {
return nil, errors.New("imposible to init the events manager component because the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY or AWS_REGION environment variable not set")
}

snsTopicARN := os.Getenv("SNS_TOPIC_ARN")
Expand Down

0 comments on commit 65b5ade

Please sign in to comment.