kubectl getcommand有这个标志-o来格式化输出.
是否有类似的方式来格式化kubectl describe命令的输出?
例如:
kubectl describe -o="jsonpath={...}" pods my-rc
Run Code Online (Sandbox Code Playgroud)
将为my-rc复制控制器中的pod列表打印JSON格式.但-o该describe命令不被接受.
我在kubernetes集群中的所有节点上的外部端口上公开了一项服务:root @ ubuntu:/ home #kubectl create -f nginx-service.yaml您已在集群中所有节点上的外部端口上公开了您的服务.如果要将此服务公开给外部Internet,则可能需要为服务端口(tcp:30002)设置防火墙规则以提供流量.
有关详细信息,请参阅http://releases.k8s.io/release-1.2/docs/user-guide/services-firewalls.md.服务"nginx-service"创建root @ ubuntu:/ home#
那么,无论如何都要获得kubernetes集群的外部端口?
我搜索了很多但没有得到正确的答案,helm 中的 include 和 {{}} 有什么区别。
前任 :
metadata:
name: {{ include "cluster-dev.fullname" . }}
Run Code Online (Sandbox Code Playgroud)
难道不能是这样吗
metadata:
name: {{ Values.nameOverride }}
Run Code Online (Sandbox Code Playgroud) 我知道你可以使用kubectl run创建一个带有Deployment/Job的pod.但是有可能创建一个附加了卷的卷吗?我试过运行这个命令:
kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPath": "/home/store", "name":"store"}}, "volumes":{"name":"store", "emptyDir":{}}}}' --image=ubuntu:14.04 --restart=Never -- bash
Run Code Online (Sandbox Code Playgroud)
但是音量不会出现在交互式bash中.
有没有更好的方法来创建一个可以附加到卷的pod?
我正在调试来自kubectl的日志输出,该输出指出:
Error from server (BadRequest): a container name must be specified for pod postgres-operator-49202276-bjtf4, choose one of: [apiserver postgres-operator]
Run Code Online (Sandbox Code Playgroud)
好的,这是一个解释性的错误消息,但是看看我的JSON模板,它应该只创建指定的两个容器,对吗?我错过了什么?(请原谅我的无知.)
我只使用标准的kubectl create -f命令在shell脚本中创建JSON文件.JSON部署文件如下:
{
"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata": {
"name": "postgres-operator"
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"labels": {
"name": "postgres-operator"
}
},
"spec": {
"containers": [{
"name": "apiserver",
"image": "$CCP_IMAGE_PREFIX/apiserver:$CO_IMAGE_TAG",
"imagePullPolicy": "IfNotPresent",
"env": [{
"name": "DEBUG",
"value": "true"
}],
"volumeMounts": [{
"mountPath": "/config",
"name": "apiserver-conf",
"readOnly": true
}, {
"mountPath": "/operator-conf",
"name": "operator-conf",
"readOnly": true …Run Code Online (Sandbox Code Playgroud) 我的问题很简单.
如何在pod中执行bash命令?我想用一个bash命令做一切事情?
[root@master ~]# kubectl exec -it --namespace="tools" mongo-pod --bash -c "mongo"
Error: unknown flag: --bash
Run Code Online (Sandbox Code Playgroud)
因此,命令被忽略.
[root@master ~]# kubectl exec -it --namespace="tools" mongo-pod bash -c "mongo"
root@mongo-deployment-78c87cb84-jkgxx:/#
Run Code Online (Sandbox Code Playgroud)
或者.
[root@master ~]# kubectl exec -it --namespace="tools" mongo-pod bash mongo
Defaulting container name to mongo.
Use 'kubectl describe pod/mongo-deployment-78c87cb84-jkgxx -n tools' to see all of the containers in this pod.
/usr/bin/mongo: /usr/bin/mongo: cannot execute binary file
command terminated with exit code 126
Run Code Online (Sandbox Code Playgroud)
如果它只是一个bash,它肯定有效.但是我想立刻跳进mongo shell.
我找到了一个解决方案,但它不起作用.告诉我现在是否可以这样做? 在kubernetes pod中执行多个命令(或从shell脚本执行)
谢谢.
当我跑步时kubectl -n abc-namespace describe pod my-pod-zl6m6,我得到了很多关于pod的信息以及最后的事件.
有没有办法使用kubectl describe或kubectl get命令输出pod的事件?
我正在尝试将mongo db部署与服务一起部署,如下所示:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo-deployment
labels:
app: mongo
spec:
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:5.0
ports:
- containerPort: 27017
env:
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: mongo-secret
key: mongo-user
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-secret
key: mongo-password
---
apiVersion: v1
kind: Service
metadata:
name: mongo-service
spec:
selector:
app: mongo
ports:
- protocol: TCP
port: 27017
targetPort: 27017
Run Code Online (Sandbox Code Playgroud)
尽管一切似乎都配置正确并部署,但它会进入一个CrashLoopBackOff状态而不是Running …
kubectl logs -f pod显示从头开始的所有日志,当日志很大时它会成为问题,我们必须等待几分钟才能获得最后一个日志.从远程连接时,它变得更加糟糕.有没有办法可以为最后100行日志留下日志并跟踪它们?
我有很多上下文,一种用于登台,一种用于生产,还有许多用于开发集群。复制和粘贴默认集群名称既繁琐又困难,尤其是随着时间的推移。如何重命名它们以使上下文切换更容易?