0
0
Kubernetesdevops~30 mins

Custom resources concept in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Working with Kubernetes Custom Resources
📖 Scenario: You are managing a Kubernetes cluster and want to extend its functionality by creating a custom resource to track application versions.
🎯 Goal: Learn how to define a Custom Resource Definition (CRD), create a custom resource, and view its details using kubectl commands.
📋 What You'll Learn
Create a Custom Resource Definition YAML file named appversion-crd.yaml with specified fields
Create a custom resource YAML file named myapp-v1.yaml using the CRD
Use kubectl commands to apply and view the custom resource
💡 Why This Matters
🌍 Real World
Kubernetes Custom Resources let you add your own resource types to the cluster. This is useful for managing specialized application data or configurations beyond built-in Kubernetes objects.
💼 Career
Understanding custom resources is important for Kubernetes administrators and DevOps engineers who want to extend Kubernetes capabilities or build operators.
Progress0 / 4 steps
1
Create the Custom Resource Definition YAML
Create a file named appversion-crd.yaml with a CustomResourceDefinition named appversions.example.com in the apiextensions.k8s.io/v1 API group. The CRD should define a spec with group as example.com, versions with a single version named v1 that is served and stored, and a scope of Namespaced. The names section should specify plural as appversions, singular as appversion, kind as AppVersion, and shortNames as av. Include an openAPIV3Schema with a spec containing a version field of type string.
Kubernetes
Need a hint?

Remember to follow the Kubernetes CRD structure carefully and indent YAML properly.

2
Create a Custom Resource YAML
Create a file named myapp-v1.yaml that defines a custom resource of kind AppVersion in the example.com/v1 API version. Set the metadata.name to myapp-v1 and the spec.version to 1.0.0.
Kubernetes
Need a hint?

Use the correct API version and kind matching the CRD you created.

3
Apply the CRD and Custom Resource
Use kubectl apply -f appversion-crd.yaml to create the CustomResourceDefinition, then use kubectl apply -f myapp-v1.yaml to create the custom resource.
Kubernetes
Need a hint?

Use the exact kubectl commands to apply both YAML files.

4
View the Custom Resource Details
Run kubectl get appversions to list the custom resources, then run kubectl get appversion myapp-v1 -o yaml to see the details of the myapp-v1 resource.
Kubernetes
Need a hint?

First list all appversions, then describe the specific one in YAML format.