Skip to content

Latest commit

 

History

History
80 lines (67 loc) · 2.08 KB

File metadata and controls

80 lines (67 loc) · 2.08 KB

Custom Resource Definition

Custom Resource Definition

Tips and Tricks

For simulated Practice problems visit KillerCoda.
  1. Create a Custom Resource Definition named BusTicket in the ticket.com API group.

    Solution

    apiVersion: apiextensions.k8s.io/v1
    kind: CustomResourceDefinition
    metadata:
      name: bustickets.ticket.com
    spec:
      group: ticket.com
      versions:
        - name: v1
          served: true
          storage: true
          schema:
            openAPIV3Schema:
              type: object
              properties:
                spec:
                  type: object
                  properties:
                    from:
                      type: string
                    to:
                      type: string
                    seats:
                      type: integer
      scope: Namespaced
      names:
        plural: bustickets
        singular: busticket
        kind: BusTicket
        shortNames:
        - bt

  2. Create a Custom Resource named my-ticket of type BusTicket in the default namespace.

    Solution

    kubectl apply -f - <<EOF
    apiVersion: ticket.com/v1
    kind: BusTicket
    metadata:
      name: my-ticket
    spec:
      from: "New Delhi"
      to: "Mumbai"
      seats: 5
    EOF

  3. Update the from value of the BusTicket named my-ticket in the default namespace to newvalue.

    Solution

     ```bash
     kubectl patch busticket my-ticket --type='json' -p='[{"op": "replace", "path": "/spec/from", "value": "Bangalore"}]'
     ```
     </p>