我正在关注该教程(https://www.baeldung.com/spring-boot-minikube),我想在yaml文件(simple-crud-dpl.yaml)中创建Kubernetes部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-crud
spec:
selector:
matchLabels:
app: simple-crud
replicas: 3
template:
metadata:
labels:
app: simple-crud
spec:
containers:
- name: simple-crud
image: simple-crud:latest
imagePullPolicy: Never
ports:
- containerPort: 8080
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时kubectl create -f simple-crud-dpl.yaml我得到了:
error: SchemaError(io.k8s.api.autoscaling.v2beta2.MetricTarget): invalid object doesn't have additional properties
我正在使用kubectl的最新版本:
kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Run Code Online (Sandbox Code Playgroud)
我也在本地使用minikube,如教程中所述。一切正常,直到部署和服务。我做不到。
我正在 minikube 中运行一些服务并尝试连接到 3306 端口上在 localhost(127.0.0.1) 上运行的 mysql。
我读了这个并尝试创建service和Endpoints. 但是,当我指定127.0.0.1为 IP 时,它会引发如下错误:
The Endpoints "mysql-service" is invalid: subsets[0].addresses[0].ip: Invalid value: "127.0.0.1": may not be in the loopback range (127.0.0.0/8)
我的部署如下:
---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
ports:
- protocol: TCP
port: 1443
targetPort: mysql
---
apiVersion: v1
kind: Endpoints
metadata:
name: mysql-service
subsets:
- addresses:
- ip: 127.0.0.1
ports:
- name: mysql
port: 3306
Run Code Online (Sandbox Code Playgroud)
请帮助我了解如何mysql从minikube. …
我有一个 Maven 插件,它使用application_default_credentials.json文件对谷歌云服务进行身份验证。
我试图找出使用服务帐户而不是使用我的帐户来获取默认凭据。
我尝试将GOOGLE_APPLICATION_CREDENTIALS环境变量设置为服务帐户凭据文件的路径。但是,该插件不使用此环境变量。
我知道,这可能是插件的问题。但是,我想知道有什么方法可以application-default-credentials.json使用谷歌服务帐户进行设置。
application-default-credentials.json 的格式:
{
"client_id": "76....408.apps.googleusercontent.com",
"client_secret": "d-....D0Ty",
"refresh_token": "1/r............................emnY02",
"type": "authorized_user"
}
Run Code Online (Sandbox Code Playgroud)
服务帐户的密钥格式:
{
"type": "service_account",
"project_id": "ID",
"private_key_id": "9a4.................................bbaad80",
"private_key": "-----BEGIN PRIVATE KEY-----\nMI................................e\n-----END PRIVATE KEY-----\n",
"client_email": "name@project.iam.gserviceaccount.com",
"client_id": "10..................886",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/name%40project.iam.gserviceaccount.com"
}
Run Code Online (Sandbox Code Playgroud) 我正在运行 minikube。Minikube 状态结果为:
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
Run Code Online (Sandbox Code Playgroud)
我定义了一个服务,端口配置如下:
type: NodePort
ports:
- protocol: TCP
port: 8082
targetPort: 8082
nodePort: 30082
Run Code Online (Sandbox Code Playgroud)
但是当我尝试访问以下 URL 上的服务时,它无法访问:
http://192.168.99.100:30082
http://192.168.99.100:8082
Run Code Online (Sandbox Code Playgroud)
是否必须另外定义一个 Ingress?我可以没有 Ingress 吗?哪个港口?
谢谢 - 基督徒
在服务的完整 yaml 下方:
apiVersion: v1
kind: Service
metadata:
annotations:
description: LAC 51 Service
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"description":"LAC 51 Service"},"labels":{"name":"lac51","service":"lac51-svc"},"name":"lac51-svc","namespace":"default"},"spec":{"ports":[{"name":"lac51-http-port","nodePort":30082,"port":8082,"protocol":"TCP","targetPort":8082}],"selector":{"app":"lac51"},"type":"NodePort"}}
creationTimestamp: null
labels:
name: lac51
service: lac51-svc
name: lac51-svc
selfLink: /api/v1/namespaces/default/services/lac51-svc
spec:
externalTrafficPolicy: Cluster
ports:
- name: lac51-http-port
port: 8082
protocol: TCP
targetPort: 8082
selector:
app: …Run Code Online (Sandbox Code Playgroud)