Open uniquejava opened 4 years ago
kubectl exec kubia-zgxn9 -- curl -s http://10.47.252.17 Error from server (BadRequest): pod kubia-zgxn9 does not have a host assigned
见: https://stackoverflow.com/a/50831348/2497876
关键句: perhaps it's asking for resources that no node can satisfy at the moment. 方案: kubectl describe pod kubia-zgxn9
使用descrbie命令发现是我的pod 找不到pvc, 瞬间明白。
# run shpod
kubectl apply -f https://bret.run/shpod.yml
kubectl attach --namespace=shpod -ti shpod
# 手动抓取分配给svc的clusterIP
IP=$(kubectl get svc httpenv -o go-template --template '{{ .spec.clusterIP }}')
curl http://$IP:8888/
# 使用jq过滤 (brew install jq)
curl -s http://$IP:8888/ | jq .HOSTNAME
shpod.yml
# from https://github.com/jpetazzo/shpod
apiVersion: v1
kind: Namespace
metadata:
name: shpod
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: shpod
namespace: shpod
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: shpod
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: shpod
namespace: shpod
---
apiVersion: v1
kind: Pod
metadata:
name: shpod
namespace: shpod
spec:
serviceAccountName: shpod
containers:
- name: shpod
image: bretfisher/shpod
imagePullPolicy: Always
stdin: true
tty: true
env:
- name: HOSTIP
valueFrom:
fieldRef:
fieldPath: status.hostIP
IBM Cloud Kubernetes Free Edition
不能互相访问不同account下的 docker image, 暂时是给他们的 docker image 设置了不同的 namespace.
cn.icr.io/awesome_lab/awesome-app:1.0.1
cn.icr.io/awesome_app/awesome-app:1.0.1
Development 环境
java: http://1.2.3.4:32439/awesome_app/swagger-ui.html
mysql: 1.2.3.4:32439, user1/secret1
维护 Development 上的 k8s 集群
名词解释
通过 IBM Cloud CLI 登录并切换 kubernetes context
创建 namespace, 远程构建 docker image
Alternative: 本地构建 docker image 并 push 到 ibm cloud
部署 redis/mysql/spring boot
Development 环境查看日志
pod 的名字: kubectl get pods
实时查看日志: kubectl logs + <pod 的名字>
查看日志文件
初期通过命令行而非 yaml 的方式部署 (备份)
创建 redis 的 yaml 文件
创建 MySQL 的 yaml 文件
创建 app 的 yaml 文件
References