Giter Site home page Giter Site logo

hawtio-operator's Introduction

Hawtio Operator

A Kubernetes operator based on the Operator SDK that installs and maintains Hawtio Online on a cluster.

Custom Resource

apiVersion: hawt.io/v1alpha1
kind: Hawtio
metadata:
  name: example-hawtio
spec:
  # The deployment type, either "cluster" or "namespace":
  # - cluster: Hawtio is capable of discovering and managing
  #   applications across all namespaces the authenticated user
  #   has access to.
  # - namespace: Hawtio is capable of discovering and managing
  #   applications within the deployment namespace.
  type: cluster
  # The number of desired replicas
  replicas: 1
  # The edge host name of the route that exposes the Hawtio service
  # externally. If not specified, it is automatically generated and
  # is of the form:
  #   <name>[-<namespace>].<suffix>
  # where <suffix> is the default routing sub-domain as configured for
  # the cluster.
  # Note that the operator will recreate the route if the field is emptied,
  # so that the host is re-generated.
  routeHostName: example-hawtio.192.168.64.38.nip.io
  # The version (default 'latest')
  version: latest

Features

The operator covers the following cases:

  • Creation
    • Create image stream, deployment config, config map, service and route resources
    • Create a service account as OAuth client in namespace deployment
    • Create an OAuth client in cluster deployment
  • Update
    • Reconcile the image stream tag and deployment trigger from the version field
    • Reconcile the route host from the routeHostName field
    • Support emptying the routeHostName field (recreate the route to re-generate the host)
    • Reconcile the replicas count into the deployment config
    • Reconcile the replicas count from deployment config changes
    • Support changing deployment type from / to namespace or cluster
    • Remove previous route host from OAuth client in cluster deployment
    • Trigger a rollout deployment on config map change
  • Deletion
    • Remove image stream, deployment config, config map, service and route resources
    • Remove the service account as OAuth client in namespace deployment
    • Remove the route URL from the OAuth client authorized redirect URIs in cluster deployment

Install

To create the required resources by the operator (e.g. custom resource definition, service account, roles, role binding, ...), run the following command:

$ make install

The above command must be executed on behalf of a privileged user, as the creation of the custom resource definition and the cluster role requires cluster-admin permission.

Note that the cluster role creation is optional in case you plan to only deploy Hawtio custom resources with namespace deployment type.

Deploy

To create the operator deployment, run the following command:

$ make deploy

kubectl apply -f deploy/operator.yaml -n hawtio
deployment.apps/hawtio-operator created

Test

To create and operate a Hawtio console resource, you can run the following commands:

# Create Hawtio
$ kubectl apply -f deploy/crds/hawtio_v1alpha1_hawtio_cr.yaml
hawtio.hawt.io/example-hawtio created

# Get Hawtio info
$ kubectl get hawtio
NAME             AGE   URL                                           IMAGE
example-hawtio   16s   https://example-hawtio.192.168.64.38.nip.io   docker.io/hawtio/online:latest

# Scale Hawtio
$ kubectl scale hawtio example-hawtio --replicas=3
hawtio.hawt.io/example-hawtio scaled

# Edit Hawtio resource
$ kubectl patch hawtio example-hawtio --type='merge' -p '{"spec":{"routeHostName":"hawtio.192.168.64.38.nip.io"}}'
hawtio.hawt.io/example-hawtio patched
# Check the status has updated accordingly
$ kubectl get hawtio
NAME             AGE   URL                                   IMAGE
example-hawtio   1m    https://hawtio.192.168.64.38.nip.io   docker.io/hawtio/online:latest

# Edit Hawtio config
$ kubectl edit configmap example-hawtio
configmap/example-hawtio edited
# Watch rollout deployment triggered by config change
$ kubectl rollout status deployment.v1.apps/example-hawtio
Waiting for deployment "example-hawtio" rollout to finish: 1 out of 3 new replicas have been updated...
Waiting for deployment "example-hawtio" rollout to finish: 2 out of 3 new replicas have been updated...
Waiting for deployment "example-hawtio" rollout to finish: 1 old replicas are pending termination...
deployment "example-hawtio" successfully rolled out

# Change the Hawtio version
$ kubectl patch hawtio example-hawtio --type='merge' -p '{"spec":{"version":"1.7.1"}}'
hawtio.hawt.io/example-hawtio patched
# Check the status has updated accordingly
$ kubectl get hawtio
NAME             AGE   URL                                   IMAGE
example-hawtio   1m    https://hawtio.192.168.64.38.nip.io   docker.io/hawtio/online:1.7.1
# Watch rollout deployment triggered by version change
$ kubectl rollout status deployment.v1.apps/example-hawtio
...
deployment "example-hawtio" successfully rolled out

# Delete Hawtio
$ kubectl delete hawtio example-hawtio
hawtio.hawt.io "example-hawtio" deleted

Development

To run the operator locally in order to speed up development cycle, you can run the following command:

$ make run

INFO[0000] Running the operator locally.

hawtio-operator's People

Contributors

astefanutti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.