Commit 2f3e892b authored by Ioannis Plakas's avatar Ioannis Plakas

New image

parent 1ad4ae1b
......@@ -22,12 +22,13 @@ run a command.Both the pods and the command will be provided in CRD.
git clone https://gitlab.ubitech.eu/iplakas/first-controller
cd first-controller
```
-----------------------------------------------------------
2. Kubernetes does not know/have a definition about the created type (`pgouv_types.go`)
```bash
kubectl get crds
```
![alt text](images/empty-crds.png?raw=true)
-----------------------------------------------------------
3. Install the CRD to the cluster
```bash
make manifests
......@@ -35,7 +36,7 @@ make install
```
The created resource is retrieved `kubectl get crd`
![Image of new crds](images/crds.png?raw=true)
---------------------------------------------------------
4. The generated CRD is fully described in yaml format in `config/crd/bases/ubi.ubitech.eu_pgouvs.yaml` which is generated by the corresponding go type
```go
......@@ -54,7 +55,7 @@ type PgouvStatus struct {
AliveRelplicas int32 `json:"alivereplicas,omitempty"`
}
```
-----------------------------------------------------------------
5. Now that the Kubernetes Cluster knows about the Custom Resource
its time to initiate one, we do that be updating the `config/samples/ubi_v1alpha1_pgouv` file (the name of file follows the GVK convention)
......@@ -72,7 +73,7 @@ In order to apply the instance of the resource `kubectl applay -f config/samples
![Created resource ](images/created.png)
-----------------------------------------------------------------------
6. Now that the cluster has a Custom Resource the determined logic
served with it is written in `controllers\pgouv_controller.go`
......@@ -95,7 +96,7 @@ func (r *PgouvReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
```
The reconcile logic will be called once new Events regrading the handled resource
(and the sub-Resources that owns) are detected . That's why `role-based-access-control` needs to be provided to the Controller(eg. `kubebuilder:rbac:`).
---------------------------------------------------------------
7. The difference that Reconcile Function uses in order to get to the desired state
is described in the following snippet
......@@ -115,7 +116,7 @@ is described in the following snippet
Firstly the Status of the CR is determined by retrieving the number of pods (owned by the Resource). Then the difference between `Spec` and `Status` will
determine if more Pods running the specified `Command` are needed or
Pods need to get deleted.
--------------------------------------------------------
8. The example logic in controller :
```go
......@@ -175,7 +176,7 @@ else if diff < 0 {
return reconcile.Result{}, nil
}
```
-------------------------------------------------------
9. The Reconcile function needs to have a Manger (possibly managing other controllers/reconcilers)
which is resposible for the shared depedancies (e.g Client , Cache)
The manager handles a reconcile function that is triggered by events(Add,Delete
......@@ -190,7 +191,7 @@ return ctrl.NewControllerManagedBy(mgr).
}
```
------------------------------------------------------
10. Run the Controller :
```bash
......@@ -200,13 +201,15 @@ make run
![Created resource ](images/output.png)
----------------------------------------------------------------------
11. The CR can be updated by updating the `Replicas` field on the `config/samples/ubi_v1alpha1_pgouv` and applying it to the cluster via
`kubectl apply -f `
![Created resource2 ](images/output2.png)
![Created resource2 ](images/output3.png)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment