0% found this document useful (0 votes)
289 views5 pages

Lab: Custom Resource Definition: Ensure You Have Running Cluster Deployed

A custom resource definition (CRD) allows users to create custom resource objects in Kubernetes. This lab demonstrates how to create a CRD called CronTab, create a CronTab object, view and describe the object, and then clean up by deleting the CRD. The steps include cloning a GitHub repo containing manifests, creating the CRD, verifying it was created, creating a CronTab object, viewing and describing the object, and then deleting the CRD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
289 views5 pages

Lab: Custom Resource Definition: Ensure You Have Running Cluster Deployed

A custom resource definition (CRD) allows users to create custom resource objects in Kubernetes. This lab demonstrates how to create a CRD called CronTab, create a CronTab object, view and describe the object, and then clean up by deleting the CRD. The steps include cloning a GitHub repo containing manifests, creating the CRD, verifying it was created, creating a CronTab object, viewing and describing the object, and then deleting the CRD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lab: Custom Resource Definition

Introduction:
A custom resource is an extension of the Kubernetes API that is not necessarily available in a
default Kubernetes installation. It represents a customization of a particular Kubernetes
installation. However, many core Kubernetes functions are now built using custom resources,
making Kubernetes more modular.

In this lab, you will learn:


• Creating Custom Resource Definition (CRDs)
• Creating Object using CRDS
• Cleanup

Note: Ensure you have running cluster deployed


1. Ensure that you have logged-in as root user with password as linux on kube-master node.
a. Creating a custom resource definition
To create custom objects, you must first create a custom resource definition (CRD).
1.1 Let us clone the git repository which contains manifests required for this exercise, by executing the
below command.
# git clone [Link]
Output:

Student Material – Do Not Re-distribute. For any queries contact:


[Link]@[Link] or [Link]
1.2 Let us view the manifest, by executing the below command.

# cat -n ~/k8s-crds/[Link]

Output:

Student Material – Do Not Re-distribute. For any queries contact:


[Link]@[Link] or [Link]
1.3 Let us create new namespace called custom-objects, by executing the below command.

# kubectl create namespace custom-objects


Output:

1.4 Let create the CRD, by executing the below command.


# kubectl apply -f ~/k8s-crds/[Link] -n custom-objects

Output:

1.5 Let us verify the custom object in api-resources

# kubectl api-resources | grep -i crontabs


Output:

1.6 Let us view a custom object manifest, by executing the below command.

# cat -n ~/k8s-crds/[Link]
Output:

1.7 Let us create the custom object, by executing the below command.

# kubectl apply -f ~/k8s-crds/[Link] -n custom-objects


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[Link]@[Link] or [Link]
1.8 Let us verify the newly created object, by executing the below command.

# kubectl get crontab -n custom-objects


Output:

1.9 You can also view the raw YAML data for a custom resource:
# kubectl get ct -o yaml -n custom-objects
Output:

Student Material – Do Not Re-distribute. For any queries contact:


[Link]@[Link] or [Link]
1.10 Let us describe the custom object, by executing the below command.

# kubectl describe ct -n custom-objects


Output:

1.11 Let us cleanup, by executing the below command.

# kubectl delete -f ~/k8s-crds/[Link]


Output:

1.12 Let us verify the custom object in api-resources

# kubectl api-resources | grep -i crontabs

Student Material – Do Not Re-distribute. For any queries contact:


[Link]@[Link] or [Link]

You might also like