Skip to content

Latest commit

 

History

History

swatch-producer-aws

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

build image & push to quay

QUAY_USER=lburnett
#this is a fake password
QUAY_TOKEN=Passw0rd
IMAGE=quay.io/lburnett/rhsm
IMAGE_TAG=quarkus_poc
OC_TOKEN=Passw0rd

docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io

docker -build --no-cache -t "${IMAGE}:${IMAGE_TAG}" .
docker -push "${IMAGE}:${IMAGE_TAG}"

login to openshift

oc login --token=${OC_TOKEN} --server=https://api.c-rh-c-eph.8p0c.p1.openshiftapps.com:6443

setup Virtual Environment

VENV_DIR=~/bonfire_venv
mkdir -p $VENV_DIR
python3 -m venv $VENV_DIR
. $VENV_DIR/bin/activate
pip install crc-bonfire
pip install --upgrade crc-bonfire

configure ~/.config/bonfire/config.yaml

appsFile:
  host: gitlab
  repo: insights-platform/cicd-common
  path: bonfire_configs/ephemeral_apps.yaml

apps:
- name: swatch-producer-aws # BONFIRE_APP_NAME
  components:
    - name: swatch-producer-aws # BONFIRE_COMPONENT_NAME
      host: local
      repo: /home/lburnett/code/rhsm-subscriptions/demo
      path: /deploy/clowdapp.yaml
    - parameters:
        REPLICAS: 1
        swatch-producer-aws/IMAGE: quay.io/cloudservices/swatch-producer-aws

deploy container with bonfire

IMAGE=quay.io/lburnett/rhsm
IMAGE_TAG=quarkus_poc
BONFIRE_APP_NAME=swatch-producer-aws
BONFIRE_COMPONENT_NAME=swatch-producer-aws
NAMESPACE=$(bonfire namespace reserve -d 12h)

echo $NAMESPACE

bonfire deploy -n $NAMESPACE \
--no-remove-resources $BONFIRE_COMPONENT_NAME \
-p $BONFIRE_COMPONENT_NAME/IMAGE=$IMAGE \
-i $IMAGE=$IMAGE_TAG $BONFIRE_APP_NAME

deploy container with bonfire (using app-interface settings)

#!/bin/bash

python3 -m venv .bonfire_venv
source .bonfire_venv/bin/activate

pip install --upgrade pip 'setuptools<58' wheel
pip install --upgrade 'crc-bonfire>=4.0.0'

export IMAGE_TAG=latest

bonfire deploy \
    rhsm \
    -i quay.io/cloudservices/rhsm-subscriptions=${IMAGE_TAG} \
    -i quay.io/cloudservices/swatch-producer-aws=${IMAGE_TAG} \
    -i quay.io/cloudservices/swatch-system-conduit=${IMAGE_TAG}

port-forward the deployed container

note: i have the namespace hardcoded here…​replace with the namespace you reserved

oc port-forward $(oc -n ephemeral-itjulc get -o name pod | grep fruit) 8000

test rest endpoint

curl --request POST \
  --url http://localhost:8000/api/swatch-producer-aws/internal/aws/billable_usage \
  --header 'content-type: application/json' \
  --data '{
  "account_number": "string",
  "billable_tally_snapshots": [
    {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "snapshot_date": "2022-02-16T15:44:16.793Z",
      "product_id": "string",
      "sla": "",
      "usage": "Development/Test",
      "granularity": "Daily",
      "tally_measurements": [
        {
          "hardware_measurement_type": "string",
          "metric_id": "Cores",
          "value": 0
        }
      ]
    }
  ]
}'

For running tests with Testcontainers you must first start podman service

systemctl --user enable --now podman.socket