你好,我正在使用 minikube 学习 Kubernetes。我可以在运行 minikube 的机器上通过 minikubeip:NodePort 访问服务,现在我想从其他机器通过 LAN 访问该服务。我尝试过 Ingress 但它对我不起作用。
部署文件:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: aspnetapp-deployment
labels:
app: aspnetapp
spec:
replicas: 2
selector:
matchLabels:
app: aspnetapp
template:
metadata:
labels:
app: aspnetapp
spec:
containers:
- name: aspnetapp-cn
image: localhost:5000/aspnetapp
ports:
- containerPort: 80
Run Code Online (Sandbox Code Playgroud)
服务文件:
---
apiVersion: v1
kind: Service
metadata:
name: aspnetapp-service
spec:
type: NodePort
ports:
- name: http
targetport: 80
port: 80
protocol: TCP
selector:
app: aspnetapp
Run Code Online (Sandbox Code Playgroud)
入口文件:
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: …Run Code Online (Sandbox Code Playgroud) portforwarding kubernetes minikube kubernetes-ingress kubernetes-service
我按照本教程https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes为我的设备颁发 SSL 证书使用证书管理器进入,让我们加密,我运行此错误 Issuing certificate as Secret does not exist。是我的配置错误吗?这是一个 Minikube 本地集群。
staging_issuer.yaml
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
namespace: cert-manager
spec:
acme:
# The ACME server URL
server: https://acme-staging-v02.api.letsencrypt.org/directory
# Email address used for ACME registration
email: email_address
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: letsencrypt-staging
# Enable the HTTP-01 challenge provider
solvers:
- http01:
ingress:
class: nginx
Run Code Online (Sandbox Code Playgroud)
入口.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: echo-ingress
annotations: …Run Code Online (Sandbox Code Playgroud) 我在远程计算机(k8_host)上启动了一个 minikube 实例。我正在尝试从本地计算机(client_comp)连接到它。我按照此处给出的指示进行设置并移动证书。
看来我可以在 client_comp 上成功使用 kubectl 执行 ping 操作,但收到证书错误:
$ kubectl get pods
Unable to connect to the server: x509: certificate is valid for 192.168.49.2, 10.96.0.1, 127.0.0.1, 10.0.0.1, not 192.168.1.69
Run Code Online (Sandbox Code Playgroud)
当我检查 minikube 的 IP 设置时,我得到
$minikube ip
192.168.49.2
Run Code Online (Sandbox Code Playgroud)
k8_host的ip是192.168.1.69。
如果我理解正确的话,似乎当 minikube 启动时,它会自动生成一组证书,这需要一个域。因此,它使用 k8_host 上的 minikube 本地 IP (192.168.49.2) 创建了证书。而且,当我尝试从 client_comp 进行连接时,它将主机设置为 k8_host 的网络 IP (192.168.1.69)。
我需要更新证书吗?我猜测,由于 nginx 设置为仅传递 ssl 证书(使用流),所以我不能只在 nginx 配置中添加正确的主机。
作为将来的参考,我在 minikube 设置过程中是否做错了什么?
以供参考:
~/.kube/config(在 client_comp 上)
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: [redacted]
server: …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我已部署的 Pod 之一创建一个 Service: NodePort,
\n以下是我的服务定义
\napiVersion: v1\nkind: Service\nmetadata:\n name: voting-service\n labels:\n name: voting-service\n app: demo-voting-app\nspec:\n type: NodePort\n ports:\n - port: 80\n targetPort: 80\n nodePort: 30004\n selector:\n name: voting-app-pod\n app: demo-voting-app\nRun Code Online (Sandbox Code Playgroud)\n我正在使用下面的命令部署此服务
\nkubectl create -f voting-app-service.yaml \nRun Code Online (Sandbox Code Playgroud)\n这是错误
\nThe Service "voting-service" is invalid: spec.ports[0].nodePort: Invalid value: 30004: provided port is already allocated\nRun Code Online (Sandbox Code Playgroud)\n因此,我尝试使用 netstat 和 lsof 命令查找使用端口 30004 的服务,但找不到使用该端口的任何服务。
\nThe Service "voting-service" is invalid: spec.ports[0].nodePort: Invalid value: 30004: provided port is already …Run Code Online (Sandbox Code Playgroud) 我正在按照指南将数据库连接到 kubernetes: https: //itnext.io/basic-postgres-database-in-kubernetes-23c7834d91ef
在 Windows 10 64 位上安装 Kubernetes (minikube) 后: https: //minikube.sigs.k8s.io/docs/start/
我遇到“base64”问题,其中数据库尝试连接并存储密码。因为 PowerShell 无法识别它。我想知道是否有人有任何想法如何解决这个问题并仍然使用 Windows 或其他方法,使我能够继续本指南的其余部分?
错误代码:
base64 : The term 'base64' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:131
+ ... postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decod ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (base64:String) …Run Code Online (Sandbox Code Playgroud) 我可以在 minikube 集群上设置 Ingress,如本教程所示: https ://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
但是,只能从运行 minikube 的主机在 minikube IP 上访问该服务。
如何启用来自其他主机的连接?
我有 Windows 11 家庭版(不允许 Hyper-V,只有专业版允许)。安装了 WSL2 和 Docker Desktop。
使用 Chocolatey 安装了 Minikube,但它拒绝启动。在 SO 上搜索,我在几篇文章中找到了这个建议,但它失败了。
PS C:\WINDOWS\system32> docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N] y
error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/prune": open …Run Code Online (Sandbox Code Playgroud) 我正在使用kubectl cp将jar文件从本地文件系统复制到minikube环境中POD的主目录中。但是,我可以确认复制成功的唯一方法是发出新的kubectl cp命令,将文件复制回temp目录并比较校验和。有没有办法直接查看复制的文件?
我必须在minikube中的两个POD之间进行通信,这两个POD在两个不同的端口中暴露,但是在单个节点中.
例如:
现在,在kubernetes中它动态分配一个端口,例如:POD A:30069和POD B:30070
这里的问题是:当从POD A(30069)访问POD B时,它不会自动映射Puber B(30070)的kubernetes端口.而是POD B尝试在8761端口打开.
如果我的描述令人困惑,请道歉.如果您无法解答我的问题,请随时重新检查.
谢谢你的帮助
我使用的说明运行minikube
https://kubernetes.io/docs/tutorials/hello-minikube/
我开始使用minikube:
$ minikube start --vm-driver=hyperkit
Run Code Online (Sandbox Code Playgroud)
并验证它是否成功运行.
我正在运行'Docker Community Edition'版本18.06.1-ce-mac73.
$ minikube ssh
Run Code Online (Sandbox Code Playgroud)
工作正常.
但是,当我这样做
$ docker ps
Run Code Online (Sandbox Code Playgroud)
在我的mac os主机上,它不显示任何容器.但是,当我这样做的时候
$ docker ps
Run Code Online (Sandbox Code Playgroud)
在做了minikube ssh之后,我看到了大约20个容器.
那么,docker容器真的在哪里运行?为什么docker ps在我的mac上没有显示任何容器?
谢谢.
minikube ×10
kubernetes ×8
docker ×3
kubectl ×3
devops ×1
lets-encrypt ×1
postgresql ×1
powershell ×1
ssl ×1
windows ×1