Managing Virtual Deployments with kubectl

With the kubectl command you can create, update, move, list, view, and delete a virtual deployment. The following topics detail how to manage these operations with kubectl.

Required IAM Policy for Virtual Deployments

To use a virtual deployment, an administrator must grant you the required type of access in a policy (IAM). Whether you're using the Console, the REST API with an SDK, the CLI, Kubernetes kubectl, or other tool, the correct permissions are required.

When an action produces a permission denied or unauthorized message, confirm a couple of settings with your administrator. The administrator must ensure that the correct type of access is granted and the correct compartment is specified.

For example, to allow users in the group MeshAdmins to create, update, and delete all virtual deployment in the compartment sales-app:

Allow group MeshAdmins to manage mesh-virtual-deployments in compartment sales-app

For Service Mesh IAM policy reference details for each resource, see: Service Mesh IAM Policies.

For a step-by-step guide to set up all the required IAM policies for a Service Mesh, see: Set up Policies required for Service Mesh

View Kubernetes Configuration Options for Virtual Deployments

You can view the Kubernetes CLI virtual deployment YAML configuration options by displaying the Custom Resource Definition (CRD). Use the following command:

kubectl describe crd virtualdeployments.servicemesh.oci.oracle.com

In the CRD, you see the fields used in a YAML configuration file under spec:schema:openAPIV3Schema:properties:spec. CRD output also includes information about field types, ranges, and limits. The following section provides an example of a YAML configuration file.

Create, Update, or Move a Virtual Deployment

To create a virtual deployment, use the kubectl apply command. For example:

kubectl apply -f virtual-deployment.yaml

The following is the sample yaml configuration file used to create a virtual deployment:

apiVersion: servicemesh.oci.oracle.com/v1beta1
kind: VirtualDeployment
metadata:
  name: <vs-sample-page>-version1   # Name of virtual deployment
  namespace: <sample-namespace>
spec:
  compartmentId: ocid1.compartment.oc1..aaa...
  name: <vs-sample>-v1  # Virtual deployment name inside the mesh
  description: This Virtual Deployment
  virtualService:
    ref:
      name: <vs-sample-page> # Name of parent virtual service
  accessLogging:
    isEnabled: true
  serviceDiscovery:
    type: DNS
    hostname: <vs-sample-page>-version1.example.com
  listener:
    - port: 9080
      protocol: HTTP
To update a virtual deployment with kubectl:
  1. Change the configuration file as needed.
  2. Save the file.
  3. Run the apply command again.
To move a virtual deployment to a different compartment:
  1. Update the compartment OCID to the value of the target compartment.
  2. Save the file.
  3. Run the apply command again.

Get a List of Virtual Deployments

To get a list of virtual deployments in your namespace, use the following command:

kubectl get virtualdeployments -n <namespace>

View a Virtual Deployment

To view the details of a specific virtual deployment in your namespace, use the following command:

kubectl describe virtualdeployment <name> -n <namespace>

Delete a Virtual Deployment

To delete of a specific virtual deployment in your namespace, use the following command:

kubectl delete virtualdeployment <name> -n <namespace>
Note

If any child resources exist in the virtual deployment, for example virtual a virtual deployment binding, the delete operation fails.