ham-placement

module
v0.0.0-...-4e26876 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2023 License: Apache-2.0

README

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           2m21s
Play with Examples

Register cluster CRD and clusters

% kubectl apply -f hack/test/open-cluster-management.io_managedclusters.crd.yaml
customresourcedefinition.apiextensions.k8s.io/managedclusters.cluster.open-cluster-management.io created
% kubectl apply -f hack/test/crs/clusters.yaml
namespace/raleigh created
managedcluster.cluster.open-cluster-management.io/raleigh created
namespace/toronto created
managedcluster.cluster.open-cluster-management.io/toronto created
namespace/shanghai created
managedcluster.cluster.open-cluster-management.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:  cluster.open-cluster-management.io/v1
    Kind:         Cluster
    Name:         shanghai
    Namespace:    shanghai
    UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
    API Version:  cluster.open-cluster-management.io/v1
    Kind:         Cluster
    Name:         toronto
    Namespace:    toronto
    UID:          f43e6fbe-8b32-4ee6-986c-f87fdbc83f51
  Decisions:
    API Version:  cluster.open-cluster-management.io/v1
    Kind:         Cluster
    Name:         shanghai
    Namespace:    shanghai
    UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
  Eliminators:
    API Version:        cluster.open-cluster-management.io/v1
    Kind:               Cluster
    Name:               raleigh
    Namespace:          raleigh
    UID:                54777532-d293-44de-b3b5-bfa8ffbaf9a9
  Last Update Time:     2020-06-30T02:36:28Z
  Observed Generation:  1
  Recommendations:
    Alphabet:
      API Version:  cluster.open-cluster-management.io/v1
      Kind:         Cluster
      Name:         shanghai
      Namespace:    shanghai
      UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
    Veto:
      API Version:  cluster.open-cluster-management.io/v1
      Kind:         Cluster
      Name:         shanghai
      Namespace:    shanghai
      UID:          66c83e70-4184-4eed-b593-09abb4e5d7a3
      API Version:  cluster.open-cluster-management.io/v1
      Kind:         Cluster
      Name:         toronto
      Namespace:    toronto
      UID:          f42e6fbe-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

Directories

Path Synopsis
cmd
pkg
apis/core
Package core contains core API versions.
Package core contains core API versions.
apis/core/v1alpha1
Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=core.hybridapp.io
Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=core.hybridapp.io

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL