Skip to main content

For Developers

Creating and Managing Resources

This section explains how to create and manage remote resources using Klutch. As a developer, you can provision and manage cloud or on-premise resources directly from your Kubernetes cluster using a declarative approach.

Developer Interaction with Klutch

Prerequisites

Before you begin, ensure you have:

  1. kubectl installed and configured to interact with your App Cluster.

  2. Access to a Klutch-enabled Kubernetes cluster.

    If your cluster wasn't set up by a platform operator, you need to use the klutch-bind CLI to connect to the Control Plane Cluster and bind to the resources you intend to use. For instructions on using the klutch-bind CLI, refer to the "For Platform Operators" section.

Available Resource Types

The types of resources you can create depend on the service bindings configured in your App Cluster. These can include databases, message queues, storage solutions, or any other services available in supported cloud providers or on-premise infrastructure.

These resources are represented as standard Kubernetes Custom Resources (CRs). You can list the supported Custom Resource Definitions (CRDs) just as you would with any other Kubernetes CRs using the following command:

kubectl get crds

To view the schema of a specific CRD:

kubectl explain <crd-name>

For a detailed view of the CRD's structure:

kubectl get crd <crd-name> -o yaml

Creating a Resource

To create a resource, define it using a Custom Resource (CR) YAML file and apply it to your cluster.

  1. Create a YAML file for your resource. Here's a generic template:

    apiVersion: <resource-group>/<version>
    kind: <ResourceType>
    metadata:
    name: my-resource
    spec:
    # Resource-specific fields go here
  2. Apply the YAML file to your cluster:

    kubectl apply -f my-resource.yaml
  3. Monitor the resource creation:

    kubectl get <resource-type> my-resource -w

    This command watches the resource and displays status updates. It shows whether the Custom Resource is successfully synced with the remote resource and indicates when the remote resource is ready for use.

Managing Resources

Checking Resource Status

To list resources of a specific type:

kubectl get <resource-type>

For detailed information about a specific resource:

kubectl describe <resource-type> <resource-name>

Updating Resources

To update a resource, modify its YAML file and reapply it:

kubectl apply -f updated-resource.yaml
note

Some fields may be immutable once the resource is created. The specific immutable fields depend on the resource type.

Deleting Resources

To delete a resource:

kubectl delete <resource-type> <resource-name>

This will trigger the deletion of the actual resource in the remote environment through Crossplane.

Troubleshooting

If you encounter issues while creating or managing resources, the following steps can help diagnose and potentially resolve the problem. Depending on your specific situation and level of access, some or all of these steps may be applicable:

  1. Check the resource status and events in your App Cluster:

    kubectl describe <resource-type> <resource-name>

    Look for events or status messages that might indicate the issue.

  2. Examine the logs of konnector (the component of Klutch running in your App Cluster):

    kubectl logs -n klutch-bind deployment/konnector

    This may show issues related to the communication between your App Cluster and the Control Plane Cluster.

  3. If you have access to the Control Plane Cluster and are familiar with the Crossplane setup and configuration, you can perform additional troubleshooting steps in the Control Plane Cluster. Refer to the latest official Crossplane troubleshooting guide for comprehensive instructions.

    Some key steps you can take include:

    a. Verify the status of the corresponding Crossplane XR (Composite Resource):

    kubectl get <xr-type> <xr-name> -n <namespace>

    b. Check the status of the Crossplane controllers:

    kubectl get pods -n crossplane-system

    Ensure all pods are in the Running state.

    c. Examine Crossplane controller logs:

    kubectl logs -n crossplane-system <crossplane-pod-name>

    Look for any error messages related to your resource.

    d. Verify that the provider for your resource is properly installed:

    kubectl get providers

    e. Inspect managed resources:

    kubectl get managed

    Identify any resources in a non-ready state.

    f. Check package installation status (if using Crossplane's package manager):

    kubectl get packages

Remember that as a developer, your access is typically limited to your App Cluster. Many advanced troubleshooting steps, especially those involving the Control Plane Cluster or Crossplane configuration, may require collaboration with your platform operators or additional permissions. If you suspect a bug in Klutch, please consider opening an issue in the relevant GitHub repository with a detailed description of the problem and steps to reproduce it.