k8s - Deployment

k8s - Deployment

Deployment 种更高阶资源,用于音 署应用程序并 以声明的方式升级应用,而不是通过 ReplicationController Replica Set 进行部署,它们都被认为是更底层的概念

在这里插入图片描述

通过 deployment 创建 pod

[root@k8s-master pod]# cat deployment.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80 # 容器端口

相关命令

# 创建
[root@k8s-master pod]# kubectl apply -f deployment.yaml 
# 查看deployment
[root@k8s-master pod]# kubectl get deploy
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   2/2     2            2           14h
# 查看 replicasets
[root@k8s-master pod]# kubectl get rs 
NAME                         DESIRED   CURRENT   READY   AGE
nginx-deployment-585449566   2         2         2       14h
[root@k8s-master pod]# kubectl get pod
NAME                               READY   STATUS    RESTARTS   AGE
nginx-deployment-585449566-7q9j7   1/1     Running   0          14h
nginx-deployment-585449566-hl4mr   1/1     Running   0          14h

[root@k8s-master pod]# kubectl describe deploy nginx-deployment
Name:                   nginx-deployment
Namespace:              default
CreationTimestamp:      Fri, 17 Dec 2021 04:32:37 +0800
Labels:                 app=nginx
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=nginx
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=nginx
  Containers:
   nginx:
    Image:        nginx:latest
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Progressing    True    NewReplicaSetAvailable
  Available      True    MinimumReplicasAvailable
OldReplicaSets:  <none>
NewReplicaSet:   nginx-deployment-585449566 (2/2 replicas created)
Events:          <none>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值