k8s cookbook读书笔记 第二章
2024-08-28 00:56:58
走一遍概念
- An overview of Kubernetes control
- f Working with pods
- f Working with a replication controller
- f Working with services
- f Working with volumes
- f Working with secrets
- f Working with names
- f Working with namespaces
- f Working with labels and selectors
- An overview of Kubernetes control
查看k8s版本
% kubectl version
是如何做到的
kubectl通过restful api 连接kubernetes api server
如何工作的
kubectl [command] [TYPE] [NAME] [flags]
/usr/local/bin/kubectl run my-first-nginx --image=nginx
However, you can write either a YAML file or a JSON file to perform similar operations.
# cat nginx.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: my-first-nginx
spec:
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: my-first-nginx
image: nginx
Then specify the create -f option to execute the kubectl command as follows
# kubectl create -f nginx.yaml
replicationcontroller "my-first-nginx" created
status of the replication controller
# kubectl get replicationcontrollers
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS AGE
my-first-nginx my-first-nginx nginx app=nginx 1 12s
缩写
kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS AGE
my-first-nginx my-first-nginx nginx app=nginx 1 1m
删除
# kubectl delete rc my-first-nginx
replicationcontroller "my-first-nginx" deleted
2.pods
是k8s中最小的可部署单元
每个pod被进程id,网络,进程间通信,时间命名空间隔离。
docker pull centos
# cat my-first-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: my-first-pod
spec:
containers:
- name: my-nginx
image: nginx
- name: my-centos
image: centos
command: ["/bin/sh", "-c", "while : ;do curl http://
localhost:80/; sleep 3; done"]
最新文章
- jQuery MiniUI开发系列之:安装部署
- STL Map的使用
- 判断密文加密类型hash-identifier
- 第五篇 Integration Services:增量加载-Deleting Rows
- 一个高在线(可以超过1024)多线程的socket echo server(pthreads 和 libevent扩展)
- Oracle_11g中解决被锁定的scott用户的方法(转载)
- Codeforces 432E Square Tiling(结构体+贪婪)
- iOS超全开源框架、项目和学习资料汇总:UI篇
- 理解 OAuth2.0
- Java多线程(二)关于多线程的CPU密集型和IO密集型这件事
- Less 创建css3动画@keyframes函数
- Zookeeper集群节点数量为什么要是奇数个?
- firewall 和 iptables 常用命令
- Java基础——Oracle(三)
- DW 破解方法
- sqlserver收缩日志的几种方式
- C#.NET常见问题(FAQ)-如何设置控件水平对齐,垂直对齐
- Hive SQL执行流程分析
- kafka学习之-文件存储机制
- Android-Gallery GridView ImageSwitcher 使用