diff --git a/Makefile b/Makefile index f64053de52..3aac86943c 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ GINKGO_FLAGS ?= -v version:=$(shell date +%s) NAMESPACE = rhacs +PROBE_NAMESPACE = rhacs-probe IMAGE_NAME = fleet-manager PROBE_IMAGE_NAME = probe IMAGE_TARGET = standard @@ -884,6 +885,35 @@ deploy/dev-fast/fleetshard-sync: image/build kubectl -n $(NAMESPACE) set image deploy/fleetshard-sync fleetshard-sync=$(SHORT_IMAGE_REF) kubectl -n $(NAMESPACE) delete pod -l application=fleetshard-sync +deploy/probe: IMAGE_REGISTRY?="$(external_image_registry)" +deploy/probe: IMAGE_REPOSITORY?="$(probe_image_repository)" +deploy/probe: IMAGE_TAG?="$(image_tag)" +deploy/probe: + @oc create namespace $(PROBE_NAMESPACE) --dry-run=client -o yaml | oc apply -f - + @oc create secret generic probe-credentials \ + --save-config \ + --dry-run=client \ + --from-literal=OCM_USERNAME=${USER} \ + --from-literal=OCM_TOKEN='$(shell ocm token --refresh)' \ + -o yaml | oc apply -n $(PROBE_NAMESPACE) -f - + @oc process -f ./templates/probe-template.yml --local \ + -p IMAGE_REGISTRY=$(IMAGE_REGISTRY) \ + -p IMAGE_REPOSITORY=$(IMAGE_REPOSITORY) \ + -p IMAGE_TAG=$(IMAGE_TAG) \ + | oc apply -f - -n $(PROBE_NAMESPACE) +.PHONY: deploy/probe + +undeploy/probe: IMAGE_REGISTRY="$(external_image_registry)" +undeploy/probe: IMAGE_REPOSITORY="$(probe_image_repository)" +undeploy/probe: + @oc process -f ./templates/probe-template.yml --local \ + -p IMAGE_REGISTRY=$(IMAGE_REGISTRY) \ + -p IMAGE_REPOSITORY=$(IMAGE_REPOSITORY) \ + | oc delete -f - -n $(PROBE_NAMESPACE) --ignore-not-found + @oc delete secret probe-credentials --ignore-not-found + @oc delete namespace $(PROBE_NAMESPACE) --ignore-not-found +.PHONY: undeploy/probe + tag: @echo "$(image_tag)" .PHONY: tag diff --git a/probe/README.md b/probe/README.md index 104da3ef26..c1712fbf41 100644 --- a/probe/README.md +++ b/probe/README.md @@ -38,3 +38,35 @@ make probe # or run an endless loop of probes ./probe/bin/probe start ``` + + +## Run probe on a dev cluster +##### Prerequisites +1. Switch kubectl context to the local cluster, e.g. +``` +kubectl config use-context colima +``` +2. Deploy fleet-manager +``` +make deploy/bootstrap deploy/dev +``` +For more details, see the root [README.md](../README.md) file +##### Steps + +1. Build the probe image +``` +make image/build/probe +``` +2. Deploy on the cluster +``` +make deploy/probe +``` +To deploy the probe service with a custom tag: +``` +# Deploy probe with the label created from the previous commit +make deploy/probe IMAGE_TAG=$(git rev-parse --short=7 HEAD^) +``` +##### Cleanup +``` +make undeploy/probe +``` diff --git a/probe/config/config.go b/probe/config/config.go index 3a3947afc6..0e8dfb6ec0 100644 --- a/probe/config/config.go +++ b/probe/config/config.go @@ -15,7 +15,7 @@ import ( // Config contains this application's runtime configuration. type Config struct { AuthType string `env:"AUTH_TYPE" envDefault:"RHSSO"` - CentralSpecs CentralSpecs `env:"CENTRAL_SPECS" envDefault:"[{ \"cloudProvider\": \"aws\", \"region\": \"us-east-1\" }]"` + CentralSpecs CentralSpecs `env:"CENTRAL_SPECS" envDefault:"[{ \"cloudProvider\": \"standalone\", \"region\": \"standalone\" }]"` FleetManagerEndpoint string `env:"FLEET_MANAGER_ENDPOINT" envDefault:"http://127.0.0.1:8000"` MetricsAddress string `env:"METRICS_ADDRESS" envDefault:":7070"` RHSSOClientID string `env:"RHSSO_SERVICE_ACCOUNT_CLIENT_ID"` diff --git a/probe/config/config_test.go b/probe/config/config_test.go index a464f0bc37..ce61197fa7 100644 --- a/probe/config/config_test.go +++ b/probe/config/config_test.go @@ -65,8 +65,8 @@ func TestGetConfig_CentralSpecDefault(t *testing.T) { require.NoError(t, err) assert.Equal(t, CentralSpecs{ { - CloudProvider: "aws", - Region: "us-east-1", + CloudProvider: "standalone", + Region: "standalone", }, }, cfg.CentralSpecs) } diff --git a/templates/probe-template.yml b/templates/probe-template.yml new file mode 100644 index 0000000000..167fb90fa7 --- /dev/null +++ b/templates/probe-template.yml @@ -0,0 +1,91 @@ +--- +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: fleet-manager-probe + annotations: + openshift.io/display-name: Fleet Manager Probe + description: ACS Services Fleet Manager Probe + tags: golang + iconClass: icon-shadowman +labels: + template: fleet-manager-probe +parameters: + - name: IMAGE_REGISTRY + displayName: Image Registry + required: true + - name: IMAGE_REPOSITORY + displayName: Image Repository + required: true + - name: IMAGE_TAG + displayName: Image tag + value: latest + - name: FLEET_MANAGER_ENDPOINT + displayName: Fleet Manager Endpoint + value: http://fleet-manager.rhacs:8000 + - name: CENTRAL_SPECS + display: Central Specifications + value: '[{ "cloudProvider": "standalone", "region": "standalone" }]' + - name: CPU_REQUESTS + displayName: CPU Requests + value: 100m + - name: CPU_LIMITS + displayName: CPU Limits + value: 100m + - name: MEMORY_REQUESTS + displayName: Memory Requests + value: 128Mi + - name: MEMORY_LIMITS + displayName: Memory Limits + value: 128Mi +objects: + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: probe + labels: + app: probe + spec: + replicas: 1 + selector: + matchLabels: + app: probe + strategy: + type: Recreate + template: + metadata: + labels: + app: probe + spec: + containers: + - name: probe + image: "${IMAGE_REGISTRY}/${IMAGE_REPOSITORY}:${IMAGE_TAG}" + imagePullPolicy: IfNotPresent + env: + - name: FLEET_MANAGER_ENDPOINT + value: ${FLEET_MANAGER_ENDPOINT} + - name: AUTH_TYPE + value: OCM + - name: OCM_USERNAME + valueFrom: + secretKeyRef: + name: probe-credentials + key: OCM_USERNAME + - name: OCM_TOKEN + valueFrom: + secretKeyRef: + name: probe-credentials + key: OCM_TOKEN + - name: CENTRAL_SPECS + value: ${CENTRAL_SPECS} + ports: + - name: monitoring + containerPort: 7070 + resources: + requests: + cpu: ${CPU_REQUESTS} + memory: ${MEMORY_REQUESTS} + limits: + cpu: ${CPU_LIMITS} + memory: ${MEMORY_LIMITS} + terminationGracePeriodSeconds: 300