Chạy câu lệnh như hình dưới để cobô thể tạo thêm 1 API mới dưới dạng webapp/v1 và 1 kind mới (CRD) là Guestbook trên đó
Khi đó sẽ có 1 số tùy chọn để người dùng có thể tạo Custom Resource cho CRD được tạo
Test it out
Mình sẽ cần 1 cụm k8s để chạy. Ở đây sẽ sử dụng cụm k8s được tạo trong issue kubernetes-the-hard-way
Cài đặt CRD mới vào cụm bằng lệnh make install
Chạy controller dưới dạng chạy nền
Install Instances of Custom Resources
Sử dụng lện này để cài đặt kubectl apply -f config/samples/
Run it on your Cluster
Build và đẩy Image lên trên kho lưu trữ, ở đây ta sử dụng Dockerhub do IMG chỉ định ( ở đây ta chọn registry là docker.io vì nó đại diện cho Docker Hub, minhson7112/kube-buil:latest là project name, images và tag của chúng) nhưng trước đó phải login vào Docker nếu không sẽ xảy ra lỗi truy cập Docker
Sau đó ta có thể vào Docker Hub để kiểm tra coi Image đã được đẩy lên chưa
Triển khai Controller vào Cluster với image được chỉ định bởi IMG
Cuối cùng mình có thể kiểm tra coi có thưc sự tạo được CR chưa. Vì nó cũng tương tự như các thành phần có trước của Kubernetes nên ta có thể chạy lệnh kubectl get Guestbook như hình bên dưới để kiểm tra
Install Kubebuilder
Trước tiên là cài đặt golang, docker, kubectl nếu chưa có
Sau đó cài đặt kubebuilder vào máy
Create a Project
Create an API
Khi đó sẽ có 1 số tùy chọn để người dùng có thể tạo Custom Resource cho CRD được tạo
Test it out
Mình sẽ cần 1 cụm k8s để chạy. Ở đây sẽ sử dụng cụm k8s được tạo trong issue
kubernetes-the-hard-way
Cài đặt CRD mới vào cụm bằng lệnh
make install
Chạy controller dưới dạng chạy nền
Install Instances of Custom Resources
Sử dụng lện này để cài đặt
kubectl apply -f config/samples/
Run it on your Cluster
Build và đẩy Image lên trên kho lưu trữ, ở đây ta sử dụng Dockerhub do IMG chỉ định ( ở đây ta chọn
registry
làdocker.io
vì nó đại diện choDocker Hub
,minhson7112/kube-buil:latest
là project name, images và tag của chúng) nhưng trước đó phải login vào Docker nếu không sẽ xảy ra lỗi truy cập DockerSau đó ta có thể vào Docker Hub để kiểm tra coi Image đã được đẩy lên chưa
Triển khai Controller vào Cluster với image được chỉ định bởi IMG
Cuối cùng mình có thể kiểm tra coi có thưc sự tạo được CR chưa. Vì nó cũng tương tự như các thành phần có trước của Kubernetes nên ta có thể chạy lệnh
kubectl get Guestbook
như hình bên dưới để kiểm tra