This topic describes how to associate an EIP address with a pod in a serverless Kubernetes cluster or with a pod on a virtual node of a dedicated or managed Kubernetes cluster.
- You can easily deploy an application that uses serverless containers.
- Services provided by the application can be more quickly accessed.
- Your pod can access the Internet without the need of a VPC NAT gateway.
- Your target application can be accessed through the Internet without the need of an SLB instance.
- Either a serverless Kubernetes cluster is created, or a virtual node is created in a dedicated or managed Kubernetes cluster. For more information, see Create a serverless Kubernetes cluster or Deploy a virtual node.
- The corresponding port for the target application that you want to run is enabled
in the security group of the target Kubernetes cluster.
Note The Nginx application is used as an example. Therefore, port 80 must be enabled in the security group of the target Kubernetes cluster.
- Log on to the VPC console to create an EIP address. For more information, see Create an EIP.
Note You must create an EIP address in the same region where the target Kubernetes cluster is located.
- Log on to the Container Service console.
- In the left-side navigation pane under Container Service-Kubernetes, choose .
- In the upper-right corner, click Create by Template.
- Select the target cluster and namespace, select an example template or customize a
template, and then click DEPLOY.
You can use the following YAML template to create a pod:Note You must replace
<youreipInstanceId>with the EIP ID obtained in step 1.
apiVersion: v1 kind: Pod metadata: name: nginx annotations: "k8s.aliyun.com/eci-eip-instanceid": "<youreipInstanceId>" spec: containers: - image: registry-vpc.cn-hangzhou.aliyuncs.com/jovi/nginx:alpine imagePullPolicy: Always name: nginx ports: - containerPort: 80 name: http protocol: TCP restartPolicy: OnFailure
- In the left-side navigation pane under Container Service-Kubernetes, choose to view the pod status.
- In your browser, enter the URL http://ip address to access the welcome page of Nginx.
Note For this URL, you must enter the IP address obtained in step 1.