diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 501dd1e..a24cbbf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/Tiltfile b/Tiltfile index 90d048a..9ae5e20 100644 --- a/Tiltfile +++ b/Tiltfile @@ -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') @@ -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)) @@ -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': @@ -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 @@ -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) diff --git a/release/obd-kardinal.yaml b/release/obd-kardinal.yaml index 937acee..1762708 100644 --- a/release/obd-kardinal.yaml +++ b/release/obd-kardinal.yaml @@ -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 @@ -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: @@ -331,4 +339,77 @@ spec: port: 8070 targetPort: 8070 protocol: TCP - appProtocol: HTTP \ No newline at end of file + 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 diff --git a/src/libraries/events/eventsmanager.go b/src/libraries/events/eventsmanager.go index b49a24c..f34f1e2 100644 --- a/src/libraries/events/eventsmanager.go +++ b/src/libraries/events/eventsmanager.go @@ -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")