我在 Ubuntu 20.04.3 LTS 上运行 microk8s v1.22.2。
输出来自/etc/hosts:
127.0.0.1 localhost
127.0.1.1 main
Run Code Online (Sandbox Code Playgroud)
摘自microk8s status:
addons:
enabled:
dashboard # The Kubernetes dashboard
ha-cluster # Configure high availability on the current node
ingress # Ingress controller for external access
metrics-server # K8s Metrics Server for API access to service metrics
Run Code Online (Sandbox Code Playgroud)
我检查了正在运行的仪表板 ( kubectl get all --all-namespaces):
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/calico-node-2jltr 1/1 Running 0 23m
kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 …Run Code Online (Sandbox Code Playgroud) 我使用microk8s的ubuntu
我正在尝试运行一个简单的 hello world 程序,但在pod创建时出现错误。
kubelet 没有配置 ClusterDNS IP,无法使用“ClusterFirst”策略创建 Pod。回退到“默认”政策
这是我正在尝试应用的deployment.yaml文件。
apiVersion: v1
kind: Service
metadata:
name: grpc-hello
spec:
ports:
- port: 80
targetPort: 9000
protocol: TCP
name: http
selector:
app: grpc-hello
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: grpc-hello
spec:
replicas: 1
selector:
matchLabels:
app: grpc-hello
template:
metadata:
labels:
app: grpc-hello
spec:
containers:
- name: esp
image: gcr.io/endpoints-release/endpoints-runtime:1
args: [
"--http2_port=9000",
"--backend=grpc://127.0.0.1:50051",
"--service=hellogrpc.endpoints.octa-test-123.cloud.goog",
"--rollout_strategy=managed",
]
ports:
- containerPort: 9000
- …Run Code Online (Sandbox Code Playgroud) 我正在使用 Helm 3 和 microk8s。当我尝试试运行时:
microk8s.helm install <...> --dry-run --debug
Run Code Online (Sandbox Code Playgroud)
我看到类似的错误
Error: YAML parse error on ./templates/deployment.yaml: error converting YAML to JSON: yaml: mapping values are not allowed in this context
helm.go:76: [debug] error converting YAML to JSON: yaml: mapping values are not allowed in this context
YAML parse error on ./templates/deployment.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
/home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:129
helm.sh/helm/v3/pkg/releaseutil.SortManifests
/home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:98
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
/home/circleci/helm.sh/helm/pkg/action/install.go:455
helm.sh/helm/v3/pkg/action.(*Install).Run
/home/circleci/helm.sh/helm/pkg/action/install.go:214
main.runInstall
...
Run Code Online (Sandbox Code Playgroud)
我发现了几个有类似错误的问题,但答案通常只是要求读取图表代码。我有一个很大的图表,需要自己调试这个错误。猜测它抱怨哪一行似乎没有意义。
有没有办法知道配置中究竟有什么问题?
我试图按照入门 docker 的教程进行操作,但是当您必须使用 kuberetes 时,我陷入了困境。我正在使用 microk8s 创建集群。
我的 Dockerfile:
FROM node:6.11.5WORKDIR /usr/src/app
COPY package.json .
RUN npm install
COPY . .
CMD [ "npm", "start" ]
Run Code Online (Sandbox Code Playgroud)
我的 bb.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: bb-demo
namespace: default
spec:
replicas: 1
selector:
matchLabels:
bb: web
template:
metadata:
labels:
bb: web
spec:
containers:
- name: bb-site
image: bulletinboard:1.0
---
apiVersion: v1
kind: Service
metadata:
name: bb-entrypoint
namespace: default
spec:
type: NodePort
selector:
bb: web
ports:
- port: 8080
targetPort: 8080
nodePort: 30001 …Run Code Online (Sandbox Code Playgroud) 我正在添加一个入口,如下所示:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cheddar
spec:
rules:
- host: cheddar.213.215.191.78.nip.io
http:
paths:
- backend:
service:
name: cheddar
port:
number: 80
path: /
pathType: ImplementationSpecific
Run Code Online (Sandbox Code Playgroud)
但日志抱怨:
W0205 15:14:07.482439 1 warnings.go:67] extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
time="2021-02-05T15:14:07Z" level=info msg="Updated ingress status" namespace=default ingress=cheddar
W0205 15:18:19.104225 1 warnings.go:67] networking.k8s.io/v1beta1 IngressClass is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 IngressClassList
Run Code Online (Sandbox Code Playgroud)
为什么?什么是正确的 yaml 使用?我目前在 microk8s 1.20
我正在运行带有 multipass hyperkit 的 Ubuntu VM,并且运行 microk8s。在 VM 内,所有内容均可通过 skaffold/kubectl 端口转发进行检查和使用。例如:
\n$ multipass list\nName State IPv4 Image\nmicrok8s-vm Running 192.168.64.2 Ubuntu 20.04 LTS\n 10.0.1.1\n 172.17.0.1\n 10.1.254.64\nRun Code Online (Sandbox Code Playgroud)\nPort forwarding service/my-app in namespace default, remote port 80 -> 127.0.0.1:4503
在虚拟机内:curl localhost:4503\xe2\x9c\x85
来自主持人:curl 192.168.64.2:4503
我知道虚拟机可以通过端口 80 访问,因为curl 192.168.64.2返回默认的 ngnix 未找到页面。FWIW 我从未安装过 ngnix 并且该服务似乎没有运行/无法将其关闭。
我已经在这个问题上呆了一天了,我被难住了。我什至尝试了 Vbox 驱动程序并手动配置了桥接适配器。我什至创建了自己的适配器......
\n$ multipass exec -- microk8s-vm sudo bash -c "cat > /etc/netplan/60-bridge.yaml" <<EOF\nnetwork:\n ethernets:\n enp0s8: # …Run Code Online (Sandbox Code Playgroud) 我想看看目前是否可以在 2020 M1 MacBook air 上本地运行 Kubernetes。
我需要的环境比较简单,只是为了看一些教程。举个例子,这个操作符-sdk 指南。
到目前为止,我已经尝试过microk8s和minikube,因为它们是我之前在其他机器上使用过的工具。
对于这两个,我brew在打开终端应用程序“with Rosetta 2”(即像这样)后安装了它们。我的进度是:
Minikube
当我运行时minikube start --driver=docker(已经安装了Docker Desktop for M1的技术预览版),出现初始化错误。在我看来,这里正在跟踪https://github.com/kubernetes/minikube/issues/9224。
Microk8s
microk8s install要求安装multipass,然后出现错误An error occurred with the instance when trying to start with 'multipass': returned exit code 2. Ensure that 'multipass' is setup correctly and try again.。Multipass 显示microk8s-vm卡在启动中。我认为这可能与这个问题有关https://github.com/canonical/multipass/issues/1857。
我知道我可能会更好地追查这些问题以寻求有关这些特定错误的帮助。如果目前可以/建议设置基本的 Kubernetes 环境以在 M1 mac …
对于 MicroK8s 的存储附加组件,默认情况下,持久性卷声明是/var/snap/microk8s/common/default-storage在主机系统下给定的存储。这怎么能改变呢?
查看hostpath-provisionerpod的声明,显示有一个名为PV_DIR指向的环境设置/var/snap/microk8s/common/default-storage- 似乎是我想要更改的内容,但是如何做到这一点?
不确定我是问一个 MicroK8s 特定问题,还是这是否适用于 Kubernetes 的一般问题?
$ microk8s.kubectl describe -n kube-system pod/hostpath-provisioner-7b9cb5cdb4-q5jh9
Name: hostpath-provisioner-7b9cb5cdb4-q5jh9
Namespace: kube-system
Priority: 0
Node: ...
Start Time: ...
Labels: k8s-app=hostpath-provisioner
pod-template-hash=7b9cb5cdb4
Annotations: <none>
Status: Running
IP: ...
IPs:
IP: ...
Controlled By: ReplicaSet/hostpath-provisioner-7b9cb5cdb4
Containers:
hostpath-provisioner:
Container ID: containerd://0b74a5aa06bfed0a66dbbead6306a0bc0fd7e46ec312befb3d97da32ff50968a
Image: cdkbot/hostpath-provisioner-amd64:1.0.0
Image ID: docker.io/cdkbot/hostpath-provisioner-amd64@sha256:339f78eabc68ffb1656d584e41f121cb4d2b667565428c8dde836caf5b8a0228
Port: <none>
Host Port: <none>
State: Running
Started: ...
Last State: Terminated
Reason: Unknown
Exit Code: 255
Started: ...
Finished: …Run Code Online (Sandbox Code Playgroud) 我有一个在 Kubernetes 集群中运行的 NodeJs 应用程序(我使用的是microk8s)。我还按照官方步骤在 Kubernetes 上设置 Elasticsearch。
但是我无法连接到 Elasticsearch 集群。我收到此错误:
ConnectionError: self signed certificate in certificate chain
Run Code Online (Sandbox Code Playgroud)
这是我的连接的代码片段:
ConnectionError: self signed certificate in certificate chain
Run Code Online (Sandbox Code Playgroud)
我在这里创建了这个问题的最小复制:https : //github.com/flolu/elasticsearch-k8s-connection。(设置说明在自述文件中)
基本上,在 Docker compose 中运行 Elasticsearch 时一切正常,但在 Kubernetes 中运行时无法连接。
造成这种情况的原因可能是我没有正确设置TLS证书,但我还没有找到任何相关信息。在创建 ES 客户端或在集群级别时,我是否在我的 NodeJs 应用程序中配置它?
最近,我尝试在裸机服务器上使用 microk8s 和默认入口控制器设置 LetsEncrypt。
我在网上找到了一些非常有用的指南,但似乎最近对 microk8s 进行了更新,改变了入口控制器的配置方式。
为了节省大家的时间,我准确地写下了我所做的事情。
如果您遇到困难或需要更好地理解,这里有一些有用的资源。
https://cert-manager.io/docs/installation/kubernetes/
https://cert-manager.io/docs/tutorials/acme/ingress/
该链接对于故障排除非常有用
microk8s ×10
kubernetes ×9
cert-manager ×1
docker ×1
http ×1
kubectl ×1
kubelet ×1
lets-encrypt ×1
macos ×1
minikube ×1
multipass ×1
node.js ×1
skaffold ×1
typescript ×1
yaml ×1