Giter VIP home page Giter VIP logo

ham-placement's Introduction

ham-placement

Build GoDoc Go Report Card Code Coverage License Image

Table of Contents generated with DocToc

PlacementRule Operator of Hybrid Application Model to decide target to deploy

What is the PlacementRule in Hybrid Application Model

It is a resource to let user define where to deploy their application components.

Community, discussion, contribution, and support

Check the CONTRIBUTING Doc for how to contribute to the repo.


Getting Started

Prerequisites

  • git v2.18+
  • Go v1.13.4+
  • operator-sdk v0.17.0
  • Kubernetes v1.14+
  • kubectl v1.14+

Check the Development Doc for how to contribute to the repo.

Quick Start

Clone PlacementRule Repository

$ mkdir -p "$GOPATH"/src/github.com/hybridapp-io
$ cd "$GOPATH"/src/github.com/hybridapp-io
$ git clone https://github.com/hybridapp-io/ham-placement.git
$ cd "$GOPATH"/src/github.com/hybridapp-io/ham-placement

Build Deployable Operator

Build the ham-placementrule and push it to a registry. Modify the example below to reference a container reposistory you have access to.

$ operator-sdk build quay.io/<user>/ham-placementrule:v0.1.0
$ sed -i 's|REPLACE_IMAGE|quay.io/johndoe/ham-placementrule:v0.1.0|g' deploy/operator.yaml
$ docker push quay.io/johndoe/ham-placementrule:v0.1.0

Install Deployable Operator

Register the CRD.

$ kubectl apply -f deploy/crds

Setup RBAC and deploy.

$ kubectl create -f deploy

Verify ham-placementrule is up and running.

$ kubectl get deployment
NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
ham-placementrule   1/1     1            1           2m20s

Play with Examples

Register cluster CRD and clusters

% kubectl apply -f hack/test/cluster-registry-crd.yaml
customresourcedefinition.apiextensions.k8s.io/clusters.clusterregistry.k8s.io created
% kubectl apply -f hack/test/crs/clusters.yaml
namespace/raleigh created
cluster.clusterregistry.k8s.io/raleigh created
namespace/toronto created
cluster.clusterregistry.k8s.io/toronto created
namespace/shanghai created
cluster.clusterregistry.k8s.io/shanghai created
% kubectl get clusters --all-namespaces --show-labels
NAMESPACE   NAME      AGE   LABELS
raleigh     raleigh   38s   cloud=IBM,datacenter=raleigh,environment=Dev,name=raleigh,owner=marketing,region=US,vendor=ICP
shanghai    shanghai  38s   cloud=IBM,datacenter=shanghai,environment=Dev,name=shanghai,owner=dev,region=China,vendor=ICP
toronto     toronto   38s   cloud=IBM,datacenter=toronto,environment=Dev,name=toronto,owner=marketing,region=US,vendor=ICP

Create the sample board cR.

% kubectl apply -f examples/board.yaml
placementrule.core.hybridapp.io/board created
% kubectl get placementrule
NAME    AGE
board   21s

 % kubectl describe placementrule
Name:         board
Namespace:    default
API Version:  core.hybridapp.io/v1alpha1
Kind:         PlacementRule
...
Spec:
  Advisors:
    Name:    alphabet
    Weight:  60
    Name:    veto
    Rules:
      Resources:
        Name:       raleigh
        Namespace:  raleigh
    Type:           predicate
    Weight:         50
  Decision Weight:  5
  Replicas:         1
  Target Labels:
    Match Labels:
      Cloud:  IBM
Status:
  Candidates:
    API Version:  clusterregistry.k8s.io/v1alpha1
    Kind:         Cluster
    Name:         shanghai
    Namespace:    shanghai
    UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
    API Version:  clusterregistry.k8s.io/v1alpha1
    Kind:         Cluster
    Name:         toronto
    Namespace:    toronto
    UID:          f43e6fbe-8b32-4ee6-986c-f87fdbc83f51
  Decisions:
    API Version:  clusterregistry.k8s.io/v1alpha1
    Kind:         Cluster
    Name:         shanghai
    Namespace:    shanghai
    UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
  Eliminators:
    API Version:        clusterregistry.k8s.io/v1alpha1
    Kind:               Cluster
    Name:               raleigh
    Namespace:          raleigh
    UID:                54577532-d293-44de-b3b5-bfa8ffbaf9a9
  Last Update Time:     2020-06-30T02:36:28Z
  Observed Generation:  1
  Recommendations:
    Alphabet:
      API Version:  clusterregistry.k8s.io/v1alpha1
      Kind:         Cluster
      Name:         shanghai
      Namespace:    shanghai
      UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
    Veto:
      API Version:  clusterregistry.k8s.io/v1alpha1
      Kind:         Cluster
      Name:         shanghai
      Namespace:    shanghai
      UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
      API Version:  clusterregistry.k8s.io/v1alpha1
      Kind:         Cluster
      Name:         toronto
      Namespace:    toronto
      UID:          f43e6fbe-8b32-4ee6-986c-f87fdbc83f51
Events:     <none>

2 advisors are built-in with placementrule operator: alphabet and veto.

Uninstall Deployable Operator

Remove all resources created.

$ kubectl delete -f deploy
$ kubectl delete -f deploy/crds

Troubleshooting

Please refer to Troubleshooting documentation for further info.

References

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.