From 5457a5a1c23e76d10ac4443956ceb8cd1fe83854 Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Fri, 23 Aug 2024 20:32:17 +0100 Subject: [PATCH] Improve and Simplify the Getting Started Guide - Refined the sample code implementation to keep it minimal, helping users better understand the core concepts. - Streamlined the guide by focusing on the main information and removing extraneous details. - Ensured that the code and samples in the guide are consistent with the generated project. - Simplified navigation by hiding the full code, making it easier for users to follow along. - Replaced the use of the deploy image plugin with direct commands to provide more comprehensive and straightforward information. --- docs/book/src/getting-started.md | 559 +++++++----------- .../getting-started/testdata/project/PROJECT | 12 - .../project/api/v1alpha1/memcached_types.go | 6 +- .../testdata/project/cmd/main.go | 5 +- .../bases/cache.example.com_memcacheds.yaml | 5 - .../project/config/manager/manager.yaml | 3 - .../samples/cache_v1alpha1_memcached.yaml | 3 - .../controller/memcached_controller.go | 198 +------ .../controller/memcached_controller_test.go | 89 +-- .../generate_getting_started.go | 421 ++++++++++++- 10 files changed, 679 insertions(+), 622 deletions(-) diff --git a/docs/book/src/getting-started.md b/docs/book/src/getting-started.md index 29c39226571..e330cee6c4c 100644 --- a/docs/book/src/getting-started.md +++ b/docs/book/src/getting-started.md @@ -1,22 +1,32 @@ # Getting Started -## Overview +We will create a sample project to let you know how it works. This sample will: + +- Reconcile a Memcached CR - which represents an instance of a Memcached deployed/managed on cluster +- Create a Deployment with the Memcached image +- Not allow more instances than the size defined in the CR which will be applied +- Update the Memcached CR status + + -We will create a sample project to let you know how it works. This sample will: + ## Create a project @@ -28,106 +38,109 @@ cd $GOPATH/memcached-operator kubebuilder init --domain=example.com ``` + + ## Create the Memcached API (CRD): -Next, we'll create a new API responsible for deploying and managing our Memcached solution. In this instance, we will utilize the [Deploy Image Plugin][deploy-image] to get a comprehensive code implementation for our solution. +Next, we'll create the API which will be responsible for deploying and +managing Memcached(s) instances on the cluster. -``` -kubebuilder create api --group cache --version v1alpha1 --kind Memcached --image=memcached:1.4.36-alpine --image-container-command="memcached,-m=64,-o,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" --make=false +```shell +kubebuilder create api --group cache --version v1alpha1 --kind Memcached ``` ### Understanding APIs -This command's primary aim is to produce the Custom Resource (CR) and Custom Resource Definition (CRD) for the Memcached Kind. It creates the API with the group `cache.example.com` and version `v1alpha1`, uniquely identifying the new CRD of the Memcached Kind. By leveraging the Kubebuilder tool, we can define our APIs and objects representing our solutions for these platforms. While we've added only one Kind of resource in this example, you can have as many `Groups` and `Kinds` as necessary. Simply put, think of CRDs as the definition of our custom Objects, while CRs are instances of them. - -