Deploy applications to Container Service for Kubernetes using IntelliJ IDEA

更新时间:
复制 MD 格式

If you use Alibaba Cloud Container Service for Kubernetes, you can use Cloud Toolkit to quickly deploy applications. This topic describes how to use Cloud Toolkit to deploy an application from IntelliJ IDEA to Container Service for Kubernetes.

Prerequisites

Set up the Docker environment

  1. In the top menu bar of IntelliJ IDEA, 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 the Docker environment. You can connect to a local or remote environment. Then, click OK.
    • Local Docker environment:
      • If your local operating system is macOS or Linux, select Unix Socket. Then, in the Location text box, enter unix:///var/run/docker.sock.
      • If your local operating system is Windows, select TCP Connection. Then, in the URI text box, enter the URI of your local Docker, such as http://127.0.0.1:2375.
    • Remote Docker environment: Select TCP Connection. In the URI text box, enter the URI of the remote Docker environment, including the IP address and port, such as http://x.x.x.x:2375. Make sure that the HTTP service is enabled on the remote host.
    settings

Deploy the application to Container Service for Kubernetes

  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 folder.
      • Dockerfile: The Dockerfile.
      • Version: The image version number.
      Image RepositoriesSelect the region, namespace, and image repository of Container Registry.
      Note Context Directory and Dockerfile are usually detected and set automatically from your local application project.
    • On the Container tab, configure the Kubernetes Type, Controller Type, Controller, and Container parameters.deploy to kubernetes01
      Container tab.
      ParameterDescription
      Kubernetes TypeSelect Alibaba Cloud Kubernetes. This deploys the application to Alibaba Cloud Container Service for Kubernetes.
      Controller Type
      • Deployment: For stateless applications.
      • StatefulSet: For stateful applications.
      ControllerSelect the region, namespace, and corresponding application.
      ContainerSelect the corresponding 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.