[英]I wanted to do remote access in mysql kubernetes to create the tables
I'm creating a mysql pod in kubernetes and I accessed kubectl describe svc mysql to see the endpoints but even though I know the endpoints I can't do remote access with HeidiSQL I'll post my yamls below to see if anyone can help me.我正在 kubernetes 中创建一个 mysql pod 并访问kubectl describe svc mysql以查看端点,但即使我知道端点我无法使用 HeidiSQL 进行远程访问我将在下面发布我的 yamls 以查看是否有人可以帮助我.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: rafaelribeirosouza86/shopping:myql
name: mysql
imagePullPolicy: Always
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
# secret:
# secretName: mysql-pass
# items:
# - key: password
persistentVolumeClaim:
claimName: mysql-pv-claim
imagePullSecrets:
- name: regcred
---
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
# clusterIP: None
ports:
- port: 3306
selector:
app: mysql
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 20Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
I wanted to do remote access in mysql kubernetes to create the tables我想在 mysql kubernetes 中进行远程访问以创建表
Just to add to Mr @Jerry 's answer there are two ways which you can use只是为了添加 @Jerry 先生的答案,您可以使用两种方法
FIRST第一的
kubectl exec docs kubectl 执行文档
kubectl exec -it <podname> -n namespace -- <command> -<arguments-as-per-command>
SECOND第二
In case it is temporary and you want to do it using some client on your local, you can proxy the pod network to your local如果它是临时的,并且您想在本地使用某些客户端来执行此操作,您可以将 pod 网络代理到您的本地
kubectl port-forward kubectl 端口转发
$ kubectl port-forward <pod-name> <port-on-pod>:<your-local-port>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.