Skip to content

STEPHINRACHEL/app-metrics-operator

 
 

Repository files navigation

App Metrics Operator

Project health

Build Status (Travis) License (License)

The App Metrics Operator for Kubernetes provides an easy way to install and manage AeroGear App Metrics Service on Kubernetes.

Limitations

ℹ️

This operator currently only works on OpenShift. This is because it provisions `Route`s and `ImageStream`s. In future we aim to make it work on vanilla Kubernetes also.

Installation

As a user with admin permissions, you can install the app-metrics-operator and a sample CR in your OpenShift cluster as follows:

make cluster/prepare
make install

Configuration

Image Streams

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:

Table 1. Environment Variables
Name Default Purpose

APP_METRICS_IMAGE_STREAM_NAME

app-metrics-imagestream

Name of the App Metrics image stream that will be created by the operator.

APP_METRICS_IMAGE_STREAM_TAG

latest

Tag of the App Metrics image stream that will be created by the operator.

APP_METRICS_IMAGE_STREAM_INITIAL_IMAGE

docker.io/aerogear/aerogear-app-metrics:0.0.13

Initial image for the App Metrics image stream that will be created by the operator.

POSTGRES_IMAGE_STREAM_NAMESPACE

openshift

Namespace to look for the Postgres image stream.

POSTGRES_IMAGE_STREAM_NAME

postgresql

Name of the Postgres image stream to look for.

POSTGRES_IMAGE_STREAM_TAG

10

Tag of the Postgres image stream.

🔥
Re-deploying this operator with customized images will cause all instances owned by the operator to be updated.

Container Names

If you would like to modify the container names, you can use the following environment variables.

Table 2. Environment Variables
Name Default

APP_METRICS_CONTAINER_NAME

appmetrics

POSTGRES_CONTAINER_NAME

postgresql

Backups

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.

Custom Resources (aka How to get value from this operator)

AppMetricsService

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:

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

AppMetricsConfig

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:

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
...

Getting help

All AeroGear projects use the same communication channels.

Issue tracker

Our main issue tracker is AeroGear on JBoss Jira. Issues may also be created here on GitHub for individual projects.

Chat

For synchronous real-time chat, we use Matrix/IRC. These are bridged together, so you can choose which is more convenient for you: #aerogear:matrix.org on Matrix or #aerogear on FreeNode IRC.

Discussion list

For important conversations, we discuss asynchronously on this Google Groups Mailing List. This is great for discussions that should involve many people in different time zones, and allows us to easily link back to conversations in future.

Development

Prerequisites

  • 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)

Running the operator

  1. Prepare the operator project:

make cluster/prepare
  1. Run the operator (locally, not in OpenShift):

make code/run
  1. Create an App Metrics Service instance (in another terminal):

make install
  1. 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"
  1. 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:

  2. Create an App Metrics Config instance:

…​ make example-app/apply …​

  1. 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"
  1. Check the config map created:

…​ kubectl get configmap -n app-metrics example-app-metrics -o yaml …​

  1. When finished, clean up:

make cluster/clean

Security Response

If you’ve found a security issue that you’d like to disclose confidentially please contact the Red Hat Product Security team.

The App Metrics Operator is licensed under the Apache License, Version 2.0 License, and is subject to the AeroGear Export Policy.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 91.3%
  • Makefile 6.6%
  • Shell 1.4%
  • Dockerfile 0.7%