The App Metrics Operator for Kubernetes provides an easy way to install and manage AeroGear App Metrics Service on Kubernetes.
By the following commands you will create a local directory and clone this project.
$ git clone git@github.com:aerogear/app-metrics-operator.git $GOPATH/src/github.com/aerogear/app-metrics-operator
Install Minishift then install Operators on it by running the following commands.
# create a new profile to test the operator
$ minishift profile set app-metrics-operator
# enable the admin-user add-on
$ minishift addon enable admin-user
# add insecure registry to download the images from docker
$ minishift config set insecure-registry 172.30.0.0/16
# start the instance
$ minishift start
ℹ️
|
The above steps are not required in OCP > 4 since the OLM and Operators came installed by default. |
The operator uses 2 image streams and what image streams to use are configurable with environment variables.
App Metrics image stream is created within the same namespace by the operator.
However, for Postgres the image stream in openshift
namespace is used.
The following table shows the available environment variable names, along with their default values:
Name | Default | Purpose |
---|---|---|
|
|
Name of the App Metrics image stream that will be created by the operator. |
|
|
Tag of the App Metrics image stream that will be created by the operator. |
|
|
Initial image for the App Metrics image stream that will be created by the operator. |
|
|
Namespace to look for the Postgres image stream. |
|
|
Name of the Postgres image stream to look for. |
|
|
Tag of the Postgres image stream. |
🔥
|
Re-deploying this operator with customized images will cause all instances owned by the operator to be updated. |
If you would like to modify the container names, you can use the following environment variables.
Name | Default |
---|---|
|
|
|
|
The BACKUP_IMAGE
environment variable configures what image to use for backing up
the custom resources created by this operator. Default value is quay.io/integreatly/backup-container:1.0.8
.
The application-monitoring stack provisioned by the application-monitoring-operator on Integr8ly can be used to gather metrics from this operator and the AppMetrics Server. These metrics can be used by Integr8ly’s application monitoring to generate Prometheus metrics, AlertManager alerts and a Grafana dashboard.
It is required that the integr8ly/Grafana and Prometheus operators are installed. For further detail see integr8ly/application-monitoring-operator.
The following command enables the monitoring service in the operator namespace:
make monitoring/install
❗
|
The namespaces are setup manually in the files ServiceMonitor, Prometheus Rules, Operator Service, and Grafana Dashboard. Following an example from the Prometheus Rules. You should replace them if the operator is not installed in the default namespace. |
expr: |
(1-absent(kube_pod_status_ready{condition="true", namespace="app-metrics"})) or sum(kube_pod_status_ready{condition="true", namespace="app-metrics"}) < 3
[source,shell]
ℹ️
|
The command make monitoring/uninstall will uninstall the Monitor Service.
|
This is the main installation resource kind. Creation of a valid AppMetricsService CR will result in a functional App Metrics Service deployed to your namespace.
AppMetricsService
has no fields that are configurable.
An example AppMetricsService resource is available at
./deploy/crds/metrics_v1alpha1_appmetricsservice_cr.yaml
:
apiVersion: metrics.aerogear.org/v1alpha1
kind: AppMetricsService
metadata:
name: example-appmetricsservice
To create this, you can run:
kubectl apply -n app-metrics -f ./deploy/crds/metrics_v1alpha1_appmetricsservice_cr.yaml
To see the created instance then, you can run:
kubectl get appmetricsservice example-appmetricsservice -n app-metrics -o yaml
This is the service consumption resource kind. Creation of a valid AppMetricsConfig CR will write the client config to a config map in the CR namespace.
AppMetricsConfig
has no fields that are configurable.
An example AppMetricsConfig resource is available at
./deploy/crds/metrics_v1alpha1_appmetricsconfig_cr.yaml
:
apiVersion: metrics.aerogear.org/v1alpha1
kind: AppMetricsConfig
metadata:
name: example-app
To create this, you can run:
kubectl apply -n app-metrics -f ./deploy/crds/metrics_v1alpha1_appmetricsconfig_cr.yaml
To see the created instance then, you can run:
kubectl get appmetricsconfig example-app -n app-metrics -o yaml
The config map created will have the name pattern <cr-app-name>-metrics
. For the example above,
you can run the following command to get the config map.
kubectl get configmap example-app-metrics -n app-metrics -o yaml
It will have content similar to this:
apiVersion: v1
data:
SDKConfig: >-
{"url":
"https://example-appmetricsservice-appmetrics-app-metrics.openshift.cluster.hostname"}
kind: ConfigMap
-
Access to an OpenShift cluster with admin privileges to be able to create Roles. Minishift is suggested.
-
Go, Make, dep, operator-sdk, kubectl (kubectl can just be a symlink to oc)
-
Prepare the operator project:
make cluster/prepare
-
Run the operator (locally, not in OpenShift):
make code/run
-
Create an App Metrics Service instance (in another terminal):
make install
-
Watch the status of your App Metrics Service instance provisioning (optional):
watch -n1 "kubectl get po -n app-metrics && echo '' && kubectl get appmetricsservice -o yaml -n app-metrics"
-
If you want to be able to work with resources that require the local instance of your operator to be able to talk to the App Metrics instance in the cluster, then you’ll need to make a corresponding domain name available locally. Something like the following should work, by adding an entry to /etc/hosts for the example Service that’s created, then forwarding the port from the relevant Pod in the cluster to the local machine. Run this in a separate terminal, and ctrl+c to clean it up when finished:
-
Create an App Metrics Config instance:
make example-app/apply
-
Watch the status of your App Metrics Config (optional):
watch -n1 "kubectl get po -n app-metrics && echo '' && kubectl get appmetricsconfig -o yaml -n app-metrics"
-
Check the config map created:
kubectl get configmap -n app-metrics example-app-metrics -o yaml
-
When finished, clean up:
make cluster/clean
Images are automatically built and pushed to our image repository by the Jenkins in the following cases:
-
For every change merged to master a new image with the
master
tag is published. -
For every change merged that has a git tag a new image with the
<operator-version>
andlatest
tags are published.
Following the steps
-
Create a new version tag following the semver, for example
0.1.0
-
Bump the version in the version.go file.
-
Update the the CHANGELOG.MD with the new release.
-
Update any tag references in all SOP files (e.g
https://github.com/aerogear/app-metrics-operator/blob/0.1.0/SOP/SOP-operator.adoc
) -
Create a git tag with the version value, for example:
$ git tag -a 0.1.0 -m "version 0.1.0"
-
Push the new tag to the upstream repository, this will trigger an automated release by the Jenkins, for example:
$ git push upstream 0.1.0
ℹ️The image with the tag will be created and pushed to the unifiedpush-operator image hosting repository by the Jenkins.
This operator is cluster-scoped
. For further information see the Operator Scope section in the Operator Framework documentation. Also, check its roles in Deploy directory.
ℹ️
|
The operator, application and database will be installed in the namespace which will be created by this project. |
Command |
Description |
|
Creates the |
|
It will delete what was performed in the |
|
Create an Example App Metrics Config instance |
|
It will apply all less the operator.yaml. |
|
Installs Monitoring Service in order to provide metrics |
|
Uninstalls Monitoring Service in order to provide metrics, i.e. all configuration applied by |
|
Runs the operator locally for development purposes. |
|
Sets up environment for debugging proposes. |
|
Examines source code and reports suspicious constructs using vet. |
|
Formats code using gofmt. |
|
Compile image to be used in the e2e tests |
|
Compile image to be used by Jenkins |
|
It will run the coveralls. |
|
Runs unit tests |
|
Build image with the parameters required for CircleCI |
ℹ️
|
The Makefile is implemented with tasks which you should use to work with. |
This operator was developed using the Kubernetes and Openshift APIs.
Currently this project requires the usage of the v1.Route to expose the service and OAuth-proxy for authentication which make it unsupportable for Kubernetes. Also, it is using ImageStream which is from the OpenShift API specifically. In this way, this project is not compatible with Kubernetes, however, in future we aim to make it work on vanilla Kubernetes also.
If you’ve found a security issue that you’d like to disclose confidentially please contact the Red Hat Product Security team.
The UnifiedPush Operator is licensed under the Apache License, Version 2.0 License, and is subject to the AeroGear Export Policy.
All contributions are hugely appreciated. Please see our Contributing Guide for guidelines on how to open issues and pull requests. Please check out our Code of Conduct too.
There are a number of ways you can get in in touch with us, please see the AeroGear community.