deployer-operator

module
v0.0.0-...-fa67f7b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: Apache-2.0

README

Deployer Operator

Build GoDoc Go Report Card Code Coverage License Image

Table of Contents generated with DocToc

Deployer Operator

What is the Deployer Operator

Works with Virtualization Operators (KubeVirt, CloudForms, etc) in a managed cluster for deployments and day2 actions.

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.15.1
  • Kubernetes v1.14+
  • kubectl v1.14+

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

Quick Start

Ideally, 2 kubernetes clusters should be used. 1 for the hub, and 1 for the managed cluster. For this quick start, the same cluster is for the hub and managed cluster. In this example, the managed cluster toronto in namespace toronto is actually pointing to the hub cluster.

Clone Deployer Operator Repository
mkdir -p "$GOPATH"/src/github.com/IBM
cd "$GOPATH"/src/github.com/IBM
git clone https://github.com/IBM/deployer-operator.git
cd "$GOPATH"/src/github.com/IBM/deployer-operator
Build Deployer Operator

Build the deployer-operator and push it to a registry. Modify the example below to reference a container reposistory you have access to, and update cluster name and it's namespace.

operator-sdk build quay.io/johndoe/deployer-operator:v0.1.0
sed -i 's|REPLACE_IMAGE|quay.io/johndoe/deployer-operator:v0.1.0|g' deploy/operator.yaml
sed -i 's|CLUSTER_NAME|toronto|g' deploy/operator.yaml
sed -i 's|CLUSTER_NAMESPACE|toronto|g' deploy/operator.yaml
docker push quay.io/johndoe/hybriddeployable-operator:v0.1.0
Install Deployer Operator

Register the deployer-operator CRDs.

kubectl create -f deploy/crds/app.cp4mcm.ibm.com_deployers_crd.yaml
kubectl create -f deploy/crds/app.cp4mcm.ibm.com_deployersets_crd.yaml

Register the deployer-operator CRD dependencies.

kubectl create -f hack/test/app_v1alpha1_deployable_crd.yaml
kubectl create -f hack/test/app_v1beta1_application.yaml
kubectl create -f hack/test/cluster-registry-crd.yaml
kubectl create -f hack/test/clusterstatus-crd.yaml

Setup RBAC and deploy.

kubectl create -f deploy/service_account.yaml
kubectl create -f deploy/role.yaml
kubectl create -f deploy/role_binding.yaml
kubectl create -f deploy/operator.yaml

Alternatively, the operator can run locally using the operator-sdk, using the following steps:

  • Start deployer operator
  • kubeconfig points to a kubernetes cluster with admin priviliege
    • Note: if you actually have separate hub and managed clusters,
      • use environment variable HUBCLUSTERCONFIGFILE to point to the kubeconfig to hub cluster
      • environment variable KUBECONFIG to point to the kubeconfig to managed cluster
cd "$GOPATH"/src/github.ibm.com/IBMPrivateCloud/deployer-operator
export CLUSTERNAME=toronto
export CLUSTERNAMESPACE=toronto
operator-sdk run --local --namespace=""

Verify deployer-operator is up and running.

kubectl get deployment

Test Deployer Operator

Create the following CRs to setup the test. This will create a Deployer to claim capability in managed cluster. After Deployer is created, DeployerSet in cluster namespace is updated.

% kubectl apply -f ./examples/kubevirt.yaml
deployer.app.ibm.com/mykv created
% kubectl get deployerset --all-namespaces
NAMESPACE   NAME      AGE
toronto     toronto   7s
% kubectl describe deployerset -n toronto toronto
Name:         toronto
Namespace:    toronto
Labels:       <none>
Annotations:  <none>
API Version:  app.ibm.com/v1alpha1
Kind:         DeployerSet
Metadata:
  Creation Timestamp:  2020-02-03T22:50:56Z
  Generation:          1
  Resource Version:    12413955
  Self Link:           /apis/app.ibm.com/v1alpha1/namespaces/toronto/deployersets/toronto
  UID:                 a3a9e3af-46d7-11ea-9dba-00000a101bb8
Spec:
  Deployers:
    Key:  default/mykv
    Spec:
      Type:  kubevirt
Events:      <none>

Add/set default Deployer (with discovery capability).

$ kubectl apply -f ./examples/cloudform.yaml
deployer.app.ibm.com/mycf created
$ kubectl describe deployerset -n toronto toronto
Name:         toronto
Namespace:    toronto
Labels:       <none>
Annotations:  <none>
API Version:  app.ibm.com/v1alpha1
Kind:         DeployerSet
Metadata:
  Creation Timestamp:  2020-02-03T22:50:56Z
  Generation:          2
  Resource Version:    12415203
  Self Link:           /apis/app.ibm.com/v1alpha1/namespaces/toronto/deployersets/toronto
  UID:                 a3a9e3af-46d7-11ea-9dba-00000a101bb8
Spec:
  Default Deployer:  default/mycf
  Deployers:
    Key:  default/mycf
    Spec:
      Discovery:
        Gvrs:
          Group:     cloudform.ibm.com
          Resource:  virtualmachines
          Version:   v1alpha1
      Type:          cloudform
    Key:             default/mykv
    Spec:
      Type:  kubevirt
Events:      <none>
$ kubectl get virtualmachines
NAME       AGE
frontend   23m
$ kubectl get deployables -n toronto
NAME                               TEMPLATE-KIND    TEMPLATE-APIVERSION          AGE     STATUS
cloudform-default-frontend-xlclx   VirtualMachine   cloudform.ibm.com/v1alpha1   3m40s

Deploy Workloads

Go to HybridDeployable repository to play with workloads.

Troubleshooting

Please refer to Trouble shooting documentation for further info.

Hybrid Application References

Directories

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

Jump to

Keyboard shortcuts

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