我让Kubernetes在两个不同的环境中运行良好,即在我的本地环境(运行minikube的MacBook)以及Google的Container Engine(GCE,Google Cloud上的Kubernetes).我使用MacBook /本地环境开发和测试我的YAML文件,然后在完成后,在GCE上尝试它们.
目前我需要单独处理每个环境:我需要在本地环境中编辑YAML文件,并在准备好后,(git)将它们克隆到GCE环境,然后使用/部署它们.这是一个有点麻烦的过程.
理想情况下,我想使用Macbook中的kubectl轻松切换本地minikube或GCE Kubernetes环境,并轻松确定YAML文件的使用位置.有没有一种简单的方法来切换上下文来做到这一点?
我正在为 python 脚本构建 Dockerfile,它将在 minikube windows 10 系统中运行,下面是我的 Dockerfile
使用以下命令构建 docker
docker build -t python-helloworld .
并将其加载到 minikube docker Demon 中
docker save python-helloworld | (eval $(minikube docker-env) && docker load)
Docker 文件
FROM python:3.7-alpine
#add user group and ass user to that group
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
#creates work dir
WORKDIR /app
#copy python script to the container folder app
COPY helloworld.py /app/helloworld.py
#user is appuser
USER appuser
ENTRYPOINT ["python", "/app/helloworld.py"]
Run Code Online (Sandbox Code Playgroud)
pythoncronjob.yml 文件(cron …
我的 Ingress 使用了以下 YAML,它工作正常(并继续工作):
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: test-layer
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: mylocalhost.com
http:
paths:
- path: /
backend:
serviceName: test-app
servicePort: 5000
Run Code Online (Sandbox Code Playgroud)
但是,它告诉我它已被弃用,我应该改为使用networking.k8s.io/v1. 当我这样做(见下文)时,它会引发错误。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
namespace: test-layer
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: mylocalhost.com
http:
paths:
- path: /
backend:
serviceName: test-app
servicePort: 5000
Run Code Online (Sandbox Code Playgroud)
错误
error: error validating "test-ingress.yaml":
error validating data: [ValidationError(Ingress.spec.rules[0].http.paths[0].backend):
unknown field "serviceName" in io.k8s.api.networking.v1.IngressBackend,
ValidationError(Ingress.spec.rules[0].http.paths[0].backend):
unknown field "servicePort" …Run Code Online (Sandbox Code Playgroud) 几个月前我安装了minikube,并希望在有更新的版本时进行升级.
我无法找到如何升级minikube.我在这里看到了升级命令的功能请求 - https://github.com/kubernetes/minikube/issues/1171
我试图卸载minikube并再次击中另一个砖墙.我没有看到卸载minikube的命令.最接近这一点的信息不是很有用 - https://github.com/kubernetes/minikube/issues/1043
我想我们需要升级这些方法(至少每6个月左右一次).
我正在尝试使用 minikube 构建微服务映像并将其部署到在我的开发机器上运行的单节点 Kubernetes 集群。我正在使用 Google 的云原生微服务演示应用程序 Online Boutique 来了解 Kubernetes、Istio 等技术的使用。
链接到 github 存储库:microservices-demo
在遵循安装过程并运行命令skaffold run来构建和部署我的应用程序时,我收到一些错误:
Step 10/11 : RUN apt-get -qq update && apt-get install -y --no-install-recommends curl
---> Running in 43d61232617c
W: GPG error: http://deb.debian.org/debian buster InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian buster-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not …Run Code Online (Sandbox Code Playgroud) 没有任何 systemd 命令在 WSL(Ubuntu Bash 18.04)中工作。当我跑时sudo systemctl is-active kubelet,错误是output: System has not been booted with systemd as init system (PID 1). Can't operate.
: running command: sudo systemctl is-active kubelet
如何在 WSL 中启用 systemd 功能?有什么办法摆脱System has not been booted with systemd
ubuntu kubernetes windows-subsystem-for-linux minikube ubuntu-18.04
在minikube中,如何使用nodeport公开服务?
例如,我使用以下命令启动kubernetes集群,并创建并公开如下所示的端口:
$ minikube start
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
$ kubectl expose deployment hello-minikube --type=NodePort
$ curl $(minikube service hello-minikube --url)
CLIENT VALUES:
client_address=192.168.99.1
command=GET
real path=/ ....
Run Code Online (Sandbox Code Playgroud)
现在如何从主机访问公开的服务?我想minikube节点也需要配置为暴露这个端口.
我最近使用自制软件在新Mac上安装了minikube和VirtualBox.我正在遵循官方minikube教程的说明.
这就是我启动集群的方式 -
minikube start --vm-driver=hyperkit
Run Code Online (Sandbox Code Playgroud)
在跑步时,kubectl cluster-info我得到了这个
Kubernetes master is running at https://192.168.99.100:8443
CoreDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Run Code Online (Sandbox Code Playgroud)
然后我设置了minikube的上下文
kubectl config use-context minikube
Run Code Online (Sandbox Code Playgroud)
但是当我运行minikube dashboard它需要花费大量时间来获得任何输出,最终我得到了这个输出 -
http://127.0.0.1:50769/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ is not responding properly: Temporary Error: unexpected response code: 503
Temporary Error: unexpected response code: 503
Temporary Error: unexpected response code: 503
Temporary Error: unexpected response code: 503
Temporary Error: unexpected response code: 503
Temporary …Run Code Online (Sandbox Code Playgroud) 在Kubernetes minikube教程中,有一个使用Minikube Docker守护进程的命令:
$ eval $(minikube docker-env)
Run Code Online (Sandbox Code Playgroud)
这个命令到底是做什么的,也就是说究竟是什么minikube docker-env意思?
我正在运行minikube v0.24.1.在这个minikube中,我将为我的nginx应用程序创建一个Pod.而且我想从本地目录传递数据.
这意味着我想将我的本地安装$HOME/go/src/github.com/nginx到我的Pod中
我怎样才能做到这一点?
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- image: nginx:0.1
name: nginx
volumeMounts:
- mountPath: /data
name: volume
volumes:
- name: volume
hostPath:
path: /data
Run Code Online (Sandbox Code Playgroud) kubernetes ×10
minikube ×10
docker ×3
dockerfile ×2
kubectl ×1
macos ×1
macos-mojave ×1
python ×1
skaffold ×1
ubuntu ×1
ubuntu-18.04 ×1