Skip to content

Commit

Permalink
ROX-16615: Probe template (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovayur authored Mar 21, 2024
1 parent c2f6dfe commit f5d53f3
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 3 deletions.
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions probe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 1 addition & 1 deletion probe/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions probe/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
91 changes: 91 additions & 0 deletions templates/probe-template.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f5d53f3

Please sign in to comment.