This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: blog.velotio.com/v1alpha1 | |
| kind: BookStore | |
| metadata:name: example-bookstore | |
| spec: | |
| bookApp: | |
| repository: "akash125/pyapp" | |
| tag: latest | |
| imagePullPolicy: "IfNotPresent" | |
| replicas: 1 | |
| port: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type BookStoreSpec struct { | |
| BookApp BookApp `json:"bookApp,omitempty"` | |
| BookDB BookDB `json:"bookDB,omitempty"` | |
| } | |
| type BookApp struct { | |
| Repository string `json:"repository,omitempty"` | |
| Tag string `json:"tag,omitempty"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ownerReferences: | |
| - apiVersion: blog.velotio.com/v1alpha1 | |
| blockOwnerDeletion: true | |
| controller: true | |
| kind: BookStore | |
| name: example-bookstore | |
| uid: 0ef42889-deb4-11e9-ba56-42010a800256 | |
| resourceVersion: "20295281" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (r *ReconcileBookStore) BookStore(bookstore *blogv1alpha1.BookStore) error { | |
| reqLogger := log.WithValues("Namespace", bookstore.Namespace) | |
| mongoDBSvc := getmongoDBSvc(bookstore) | |
| msvc := &corev1.Service{} | |
| err := r.client.Get(context.TODO(), types.NamespacedName{Name: "mongodb-service", Namespace: bookstore.Namespace}, msvc) | |
| if err != nil { | |
| if errors.IsNotFound(err) { | |
| controllerutil.SetControllerReference(bookstore, mongoDBSvc, r.scheme) | |
| err = r.client.Create(context.TODO(), mongoDBSvc) | |
| if err != nil { return err } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (r *ReconcileBookStore) Reconcile(request reconcile.Request) (reconcile.Result, error) { | |
| reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name) | |
| reqLogger.Info("Reconciling BookStore") | |
| // Fetch the BookStore instance | |
| bookstore := &blogv1alpha1.BookStore{} | |
| err := r.client.Get(context.TODO(), request.NamespacedName, bookstore) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Watch for changes to primary resource BookStore | |
| err = c.Watch(&source.Kind{Type: &blogv1alpha1.BookStore{}}, &handler.EnqueueRequestForObject{}) | |
| if err != nil { | |
| return err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INFO[0000] Generating controller version blog.velotio.com/v1alpha1 for kind BookStore. | |
| INFO[0000] Created pkg/controller/bookstore/bookstore_controller.go | |
| INFO[0000] Created pkg/controller/add_bookstore.go | |
| INFO[0000] Controller generation complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INFO[0000] Generating api version blog.velotio.com/v1alpha1 for kind BookStore. | |
| INFO[0000] Created pkg/apis/blog/group.go | |
| INFO[0001] Created pkg/apis/blog/v1alpha1/bookstore_types.go | |
| INFO[0001] Created pkg/apis/addtoscheme_blog_v1alpha1.go | |
| INFO[0001] Created pkg/apis/blog/v1alpha1/register.go | |
| INFO[0001] Created pkg/apis/blog/v1alpha1/doc.go | |
| INFO[0001] Created deploy/crds/blog.velotio.com_v1alpha1_bookstore_cr.yaml | |
| INFO[0009] Created deploy/crds/blog.velotio.com_bookstores_crd.yaml | |
| INFO[0009] Running deepcopy code-generation for Custom Resource group versions: [blog:[v1alpha1], ] | |
| INFO[0010] Code-generation complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # tasks file for bookstore | |
| - name: Create the mongodb deployment | |
| k8s: | |
| definition: | |
| kind: Deployment | |
| apiVersion: apps/v1beta1 | |
| metadata: | |
| name: mongodb-deployment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: blog.velotio.com/v1alpha1 | |
| kind: BookStore | |
| metadata: | |
| name: my-bookstore | |
| spec: | |
| image: | |
| app: | |
| repository: akash125/pyapp | |
| tag: latest | |
| pullPolicy: IfNotPresent |