Serverless Kubernetes Container Service Supports Mounting EIPs with Pods

Method 1: Automatically Assigning an Elastic IP Address

#cat nginx-enable-eip-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx
annotations:
"k8s.aliyun.com/enable-eip": "true"
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
#kubectl apply -f nginx-enable-eip-pod.yaml
pod "nginx" created
#kubectl get pod
nginx 1/1 Running 0 20s
# kubectl describe pod
Name: nginx
Namespace: default
Node: viking-c7d16b6c584544f65bfa4eba3a8b04d63/
Start Time: Mon, 07 Jan 2019 13:19:47 +0800
Labels: <none>
Annotations: k8s.aliyun.com/allocated-eipAddress=47.96.67.132
k8s.aliyun.com/allocated-eipInstanceId=eip-bp1wtbt7vp18tgu5g7rb2
k8s.aliyun.com/enable-eip=true
kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{"k8s.aliyun.com/enable-eip":"true"},"name":"nginx","namespace":"default"},"spec":{"container...
kubernetes.io/limit-ranger=LimitRanger plugin set: cpu, memory request for container nginx
Status: Running
IP: 10.1.89.103
Containers:
nginx:
Container ID: eci://779380281b08b325b4b7a1b66c4cb9e706985b25cde0c36345af93a308745b95
Image: registry-vpc.cn-hangzhou.aliyuncs.com/jovi/nginx:alpine
Image ID:
Port: 80/TCP
State: Running
Started: Mon, 07 Jan 2019 13:19:47 +0800
Ready: True
Restart Count: 0
Requests:
cpu: 1
memory: 2Gi
Environment: <none>
...

# kubectl describe pod|grep allocated-eipAddress
Annotations: k8s.aliyun.com/allocated-eipAddress=47.96.67.132
# curl 47.96.67.132
<! DOCTYPE html>
<html>
<head>
<title>Welcome to nginx! </title>
...

Method 2: Specifying the ID of an Elastic IP Address Instance

# cat nginx-eipid-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx
annotations:
"k8s.aliyun.com/eipInstanceId": "eip-bp19trewkig3i9pnek99i"
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
# kubectl apply -f  nginx-eipid-pod.yaml
pod "nginx" created
# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 20s
# curl 47.111.20.92
<! DOCTYPE html>
<html>
<head>
<title>Welcome to nginx! </title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx! </h1>
...

About Container Service for Kubernetes

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store