https://www.cnblogs.com/yxh168/p/10898379.html k8s 规范
https://www.cnblogs.com/harlanzhang/p/10045975.html
pod 是一个服务
搭建k8s 客户端查询应用服务
kubectl get pods --namespace=logging
1.创建命名空间
Namespace
2.apiVersion: v1
kind: Namespace
metadata:
name: logging
3.kubectl create -f kube-logging.yaml
4. kubectl get ns
二.创建Service
2.1
kind: Service apiVersion: v1 metadata: name: elasticsearch namespace: logging labels: app: elasticsearch spec: selector: app: elasticsearch clusterIP: None ports: - port: 9200 name: rest - port: 9300 name: inter-node
2.2 kubectl create -f elasticsearch-svc.yaml
2.3 kubectl get services --namespace=logging
docker logs -f rancher
docker ps | grep dashboard
执行创建 kubectl create -f pod-demo.yml 2.执行删除 kubectl delete -f pod-demo.yml
查看pod中指定容器日志
kubectl logs pod-demo busybox
kubectl get pods
kubectl describe pods pod-demo
进入pod容器执行命令
kubectl exec -it pod-demo -c myapp -- /bin/sh
kubectl get pod -n kube-system -o wide
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-node
spec:
replicas: 2
template:
metadata:
labels:
app: web
spec:
containers:
- name: kube-node-demo-instance
image: yinwensheng/kube-node-demo1:v1
ports:
- containerPort: 8081
kubectl describe pods/kube-node-59bf664cbf-2qzgd
9.参考Kubernetes配置secret拉取私有仓库镜像的官方文档后
kubectl create secret docker-registry myregistrykey
--docker-server=https://index.docker.io/v1/
--docker-username=yinwensheng
--docker-password=xxxx
--docker-email=xxxx@qq.com
10.kubectl get secrets
这样我们就创建好了secret,然后再将这个secret加到yaml文件中,修改后的deployment.yaml文件如下:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-node
spec:
replicas: 2
template:
metadata:
labels:
app: web
spec:
containers:
- name: kube-node-demo-instance
image: yinwensheng/kube-node-demo1:v1
ports:
- containerPort: 8081
imagePullSecrets:
- name: myregistrykey
11.kubectl delete deployments/kube-node
12.kubectl create -f deployment.yaml
13.kubectl get pods -o wide
14.curl 10.244.2.66:8081
15.kubectl get services /kubectl get svc nginx/