[Cloud Z DB] Is it possible to reuse an IP address when creating a new service?

Print

You can reuse an IP address from a currently used service if the namespace is changed or a new service is created.

To reuse the IP, you must either submit a ticket through the support portal before deleting the service, or follow the procedure below.


NAME                TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                         AGE 
aaaa-mariadb        LoadBalancer   172.21.129.140   10.178.79.237   3306:32142/TCP,9104:32022/TCP   3d   

NAME                TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                         AGE 
bbbb-mariadb        LoadBalancer   172.21.28.178    10.178.79.226   3306:32283/TCP,9104:32007/TCP   1h


Example: Replace the IP used in aaaa-mariadb with bbbb-mariadb. 

  1. Record the IP currently used by the existing service (aaaa-mariadb), then delete the service.
    (e.g., 10.178.79.237)
    - kubectl -n <NAMESPACE> delete svc aaaa-mariadb 
  2. Backup the YAML of the new service.
    - kubectl -n <NAMESPACE> get svc bbbb-maraidb -o yaml > bbbb-mariadb-svc.yaml
  3. Delete the bbbb-mariadb service.
    - kubectl -n <NAMESPACE> delete svc bbbb-mariadb
  4. Edit bbbb-mariadb-svc.yaml to add the previous IP.
    - spec:
         add  loadBalancerIP: 10.178.79.237
  5. Recreate the bbbb-mariadb service.
    - kubectl apply -f bbbb-mariadb-svc.yaml


bbbb-mariadb-svc.yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    prometheus.io/port: "9104"
    prometheus.io/scrape: "true"
    service.kubernetes.io/ibm-load-balancer-cloud-provider-ip-type: private
  labels:
    app: mariadb
    chart: mariadb-4.2.6
    component: master
    heritage: Tiller
    release: bbbb
  name: bbbb-mariadb
  namespace: fsk-db
spec:
  loadBalancerIP: 10.178.79.237
  ports:
  - name: mysql
    port: 3306
    targetPort: mysql
  - name: metrics
    port: 9104
    targetPort: metrics
  selector:
    app: mariadb
    component: master
    release: bbbb
  sessionAffinity: None
  type: LoadBalancer

この回答は役に立ちましたか? はい いいえ

フィードバックを送信
お役に立てずに申し訳ございません。この記事を向上させるためにフィードバックをお願い致します。