...
Code Block |
---|
#verify nodeport service exists ubuntu@k8s-s1-master:~$ kubectl get svc -n onap | grep mysql mysql-nodeport NodePort 10.107.197.242 <none> 3306:3003130231/TCP,3307:3003230232/TCP 29s ubuntu@k8s-s1-master:~$ #verify the endpoints are assigned for the service #make a note of Node Port Number to use in step#5 ubuntu@k8s-s1-master:~$ kubectl describe svc mysql-nodeport -n onap Name: mysql-nodeport Namespace: onap Labels: statefulset.kubernetes.io/pod-name=sdnc-dbhost-0 Annotations: <none> Selector: statefulset.kubernetes.io/pod-name=sdnc-dbhost-0 Type: NodePort IP: 10.107.197.242 Port: sdnc-dbhost-0-port-3306 3306/TCP TargetPort: 3306/TCP NodePort: sdnc-dbhost-0-port-3306 30231/TCP Endpoints: 10.44.0.3:3306 Port: sdnc-dbhost-0-port-3307 3307/TCP TargetPort: 3307/TCP NodePort: sdnc-dbhost-0-port-3307 30232/TCP Endpoints: 10.44.0.3:3307 Session Affinity: None External Traffic Policy: Cluster Events: <none> ubuntu@k8s-s1-master:~$ |
4. Create NodePort service on both sites in "onap" namespace. Make sure the kubectl version is 1.9x. Use attached - mysql-nodeport.yaml.
Info |
---|
You can skip this step if the node port service verified in step #3 already exists. |
Code Block |
---|
ubuntu@k8s-s1-master:~$ cat mysql-nodeport.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql-nodeport
namespace: "onap"
labels:
statefulset.kubernetes.io/pod-name: sdnc-dbhost-0
spec:
ports:
- name: "sdnc-dbhost-0-port-3306"
port: 3306
targetPort: 3306
nodePort: 30231
- name: "sdnc-dbhost-0-port-3307"
port: 3307
targetPort: 3307
nodePort: 30232
type: NodePort
selector:
statefulset.kubernetes.io/pod-name: sdnc-dbhost-0
ubuntu@k8s-s1-master:~$
#create nodeport service
ubuntu@k8s-s1-master:~$ kubectl create -f mysql-nodeport.yaml
service "mysql-nodeport" created
#verify created service
ubuntu@k8s-s1-master:~$ kubectl get svc -n onap | grep mysql-nodeport
mysql-nodeport NodePort 10.107.197.242 <none> 3306:30031/TCP,3307:30032/TCP 29s
ubuntu@k8s-s1-master:~$
#verify the endpoints are assigned for the service
ubuntu@k8s-s1-master:~$ kubectl describe svc mysql-nodeport -n onap
Name: mysql-nodeport
Namespace: onap
Labels: statefulset.kubernetes.io/pod-name=sdnc-dbhost-0
Annotations: <none>
Selector: statefulset.kubernetes.io/pod-name=sdnc-dbhost-0
Type: NodePort
IP: 10.107.197.242
Port: sdnc-dbhost-0-port-3306 3306/TCP
TargetPort: 3306/TCP
NodePort: sdnc-dbhost-0-port-3306 30231/TCP
Endpoints: 10.44.0.3:3306
Port: sdnc-dbhost-0-port-3307 3307/TCP
TargetPort: 3307/TCP
NodePort: sdnc-dbhost-0-port-3307 30232/TCP
Endpoints: 10.44.0.3:3307
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
ubuntu@k8s-s1-master:~$
|
5. Setup Master-Master Replication.
...