Deploy an application to a self-managed Kubernetes cluster using IntelliJ IDEA

更新时间:
复制 MD 格式

If you have a self-managed Kubernetes cluster, you can use Cloud Toolkit to quickly deploy applications. This topic describes how to use Cloud Toolkit in IntelliJ IDEA to deploy an application to your cluster.

Prerequisites

Set up the Docker environment

  1. In the IntelliJ IDEA toolbar, click Tools > Alibaba Cloud > Preferences....
  2. In the Settings dialog box, choose Alibaba Cloud Toolkit > Docker in the navigation pane on the left.
  3. On the Docker page, configure a local or remote Docker environment, and then click OK.
    • Local Docker environment:
      • If your local operating system is macOS or Linux, select the Unix Socket check box, and then enter unix:///var/run/docker.sock in the Location
      • If your local operating system is Windows, select the TCP Connection check box, and then enter the URI of your local Docker environment in the URI text box, such as http://127.0.0.1:2375.
    • Remote Docker environment: Select the TCP Connection check box, and enter the URI of the remote Docker environment in the URI text box, such as http://x.x.x.x:2375. Make sure that the HTTP service on the remote host is enabled.
    settings

Deploy an application to a self-managed Kubernetes cluster

  1. Open your project in IntelliJ IDEA.
  2. In the top menu bar of IntelliJ IDEA, choose Tools > Alibaba Cloud > Deploy to Registry/Kubernetes > Deploy to Kubernetes.
  3. In the Deploy to Kubernetes dialog box, configure the following parameters.
    • On the Image tab, configure the Build Image and Image Repositories parameters.
      deploy to kubernetes
      Image tab.
      ParameterDescription
      NameThe name of the deployment. Use an English name.
      Build Image
      • Context Directory: The context directory.
      • Dockerfile: The Dockerfile.
      • Version: The image version number.
      Image RepositoriesSelect the region, namespace, and image repository of Container Registry.
      Note Context Directory and Dockerfile parameters are typically detected and set automatically based on your local application project.
    • On the Container tab, configure the Kubernetes Type, Kubeconfig, Controller Type, Controller, and Container parameters.
      custom kubernetes
      Container tab.
      ParameterDescription
      Kubernetes TypeSelect Custom Kubernetes to deploy the application to a self-managed Kubernetes cluster.
      KubeconfigSelect the custom deployment file.
      Controller Type
      • Deployment: For stateless applications.
      • StatefulSet: for a stateful application.
      ControllerSelect the region, namespace, and application.
      ContainerSelect the container.
  4. Click Apply, and then click Run.

Verify the result

When the deployment starts, logs are displayed in the Console area of IntelliJ IDEA. Check the logs to verify the deployment result.

If you have any questions while using Cloud Toolkit, contact us.