Code Monkey home page Code Monkey logo

xline-operator's Introduction

xline-operator

The xline-operator is a powerful tool designed to automate the process of bootstrapping, monitoring, snapshotting, and recovering an xline cluster on Kubernetes.

Getting Started

Setup RBAC for xline operator

Xline operator requires a ClusterRole with permission to create Kubernetes Custom Resource Definition (CRD).

In this example, the ClusterRole specified in examples/cluster-role.yml will bind to the default service account through examples/cluster-role-binding.yml. You can change the binding if you want.

Apply RBAC:

$ kubectl apply -f examples/cluster-role.yml
clusterrole.rbac.authorization.k8s.io/xline-operator-role created

$ kubectl apply -f examples/cluster-role-binding.yml
clusterrolebinding.rbac.authorization.k8s.io/xline-operator-rolebinding created

Inspect RBAC:

$ kubectl describe clusterrole xline-operator-role
Name:         xline-operator-role
Labels:       <none>
Annotations:  <none>
PolicyRule:
  Resources                                       Non-Resource URLs  Resource Names  Verbs
  ---------                                       -----------------  --------------  -----
  endpoints                                       []                 []              [*]
  events                                          []                 []              [*]
  persistentvolumeclaims                          []                 []              [*]
  pods                                            []                 []              [*]
  services                                        []                 []              [*]
  customresourcedefinitions.apiextensions.k8s.io  []                 []              [*]
  statefulsets.apps                               []                 []              [*]
  cronjobs.batch                                  []                 []              [*]
  xlineclusters.xlineoperator.xline.cloud         []                 []              [*]

Setup xline operator

Create a deployment:

$ kubectl apply -f examples/crd-deployment.yml
deployment.apps/my-xline-operator created

xline operator will automatically create a CRD:

$ kubectl get crd
NAME                                      CREATED AT
xlineclusters.xlineoperator.xline.cloud   -

Create an xline cluster

Create an xline cluster:

$ kubectl apply -f examples/xline-cluster-example.yml
xlinecluster.xlineoperator.xline.cloud/my-xline-cluster created

Inspect xline pods:

$ kubectl get pods
NAME                                 READY   STATUS    RESTARTS        AGE
my-xline-cluster-0                   1/1     Running   0               -
my-xline-cluster-1                   1/1     Running   0               -
my-xline-cluster-2                   1/1     Running   0               -

Resize the xline cluster

You can use kubectl scale to resize the replicas of xline servers. xlinecluster has a short name xc

$ kubectl scale xc my-xline-cluster --replicas=5
xlinecluster.xlineoperator.xline.cloud/my-xline-cluster scaled

Then we have 5 xline servers now!

$ kubectl get pods
NAME                                 READY   STATUS    RESTARTS      AGE
my-xline-cluster-0                   1/1     Running   0             -
my-xline-cluster-1                   1/1     Running   0             -
my-xline-cluster-2                   1/1     Running   0             -
my-xline-cluster-3                   1/1     Running   0             -
my-xline-cluster-4                   1/1     Running   0             -

Notice that you cannot scale your cluster size less than 3. The operator cannot work with less than 3 nodes.

$ kubectl scale xc my-xline-cluster --replicas=1
The XlineCluster "my-xline-cluster" is invalid: spec.size: Invalid value: 1: spec.size in body should be greater than or equal to 3

Delete the xline cluster

$ kubectl delete -f examples/xline-cluster-example.yml

NodeAffinity

You can use affinity to specify which nodes the xline servers should be scheduled on or which nodes should not be.

Details about affinity can be found in Kubernetes documentation.

Create an xline cluster with affinity:

$ kubectl apply -f examples/affinity-example.yml

The above example will create an xline cluster with affinity that requires the xline servers to be scheduled on nodes which have an xline pod before. In other words, the xline cluster servers will be scheduled on the same node.

You can replace the topologyKey with some other key to schedule the xline servers on different nodes shared the same topologyKey. You can also use podAntiAffinity to force the xline servers to be scheduled on different nodes.

Code of Conduct

Read the document CODE_OF_CONDUCT.md for more details.

xline-operator's People

Contributors

igxnon avatar phoenix500526 avatar bsbds avatar liangyuanpeng 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.