k8s mysql 远程访问_如何访问我的kubernetes集群外的mysql?
我在我的centos机器上运行kubernetes集群.我不想为mysql创建一个pod. MySQL安装在同一网络中的另一台机器上(机器不在kubernates专用网络中).如何从kubernetes集群中运行的pod访问mysql服务?我已尝试使用以下配置的服务和终点.但是,没有运气.apiVersion: v1kind: Servicemetadata:name: databasespec:
我在我的centos机器上运行kubernetes集群.
我不想为mysql创建一个pod. MySQL安装在同一网络中的另一台机器上(机器不在kubernates专用网络中).
如何从kubernetes集群中运行的pod访问mysql服务?
我已尝试使用以下配置的服务和终点.但是,没有运气.
apiVersion: v1
kind: Service
metadata:
name: database
spec:
ports:
- port: 13080
targetPort: 13080
protocol: TCP
---
kind: Deployment
apiVersion: v1
metadata:
name: database
subsets:
- addresses:
- ip: XX.XX.XX.XX
ports:
- port: 13080
---
kind: ReplicationController
metadata:
name: test
spec:
replicas: 1
selector:
app: test
template:
metadata:
name: test
labels:
app: test
spec:
containers:
- name: my_pods
image: my_pods
env:
- name: DATABASE_HOST
value: database
- name: DATABASE_PORT
value: "13080"
- name: DATABASE_USER
value: "SAAS"
- name: DATABASE_PASSWORD
value: "SAAS"
- name: DATABASE_NAME
value: "SAASDB"
ports:
- containerPort: 8080
imagePullSecrets:
- name: my-secret
---
apiVersion: v1
kind: Service
metadata:
name: test-service
labels:
name: test-service
spec:
type: NodePort
ports:
- port: 11544
targetPort: 8080
nodePort: 30600
selector:
name: test
更多推荐
所有评论(0)