https://github.com/argoproj/argo-rollouts/releases
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/download/v1.3.1/install.yaml
kubectl apply -f https://github.com/argoproj/argo-rollouts/releases/download/v1.3.1/dashboard-install.yaml -n argo-rollouts
查看资源
[root@master ~]# kubectl get pods -n argo-rollouts
NAME READY STATUS RESTARTS AGE
argo-rollouts-7f75b9fb76-r2zx6 1/1 Running 0 18m
argo-rollouts-dashboard-7dc4f88f5b-dj4dh 1/1 Running 0 7m28s
将argo-rollouts-dashboard暴露出来
[root@master argo-rollouts]# kubectl apply -f 03-argo-rollouts-dashboard-virtualservice.yaml
[root@master argo-rollouts]# cat 03-argo-rollouts-dashboard-virtualservice.yaml
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: argo-rollouts-dashboard
namespace: argo-rollouts
spec:
host: argo-rollouts-dashboard
trafficPolicy:
tls:
mode: DISABLE
---
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: argo-rollouts-dashboard-gateway
namespace: istio-system
spec:
selector:
app: istio-ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "argo-rollouts.yang.com"
- "rollouts.yang.com"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: argo-rollouts-dashboard-virtualservice
namespace: argo-rollouts
spec:
hosts:
- "argo-rollouts.yang.com"
- "rollouts.yang.com"
gateways:
- istio-system/argo-rollouts-dashboard-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: argo-rollouts-dashboard
port:
number: 3100
---
下载kubectl-argo-rollouts
[root@master argo-rollouts]# wget https://github.com/argoproj/argo-rollouts/releases/download/v1.3.1/kubectl-argo-rollouts-linux-amd64
[root@master argo-rollouts]# cp kubectl-argo-rollouts-linux-amd64 /usr/bin/kubectl-argo-rollouts
[root@master argo-rollouts]# chmod +x /usr/bin/kubectl-argo-rollouts
[root@master argo-rollouts]# kubectl argo rollouts
[root@master argo-rollouts]# ln -sv /usr/bin/kubectl-argo-rollouts /usr/bin/kubectl-rollouts
‘/usr/bin/kubectl-rollouts’ -> ‘/usr/bin/kubectl-argo-rollouts’
示例 部署一个rollouts
[root@master 08-argo-rollouts]# kubectl apply -f 01-argo-rollouts-demo.yaml
rollout.argoproj.io/rollouts-spring-boot-helloworld created
service/spring-boot-helloworld created
[root@master 08-argo-rollouts]# cat 01-argo-rollouts-demo.yaml
# CopyRight: MageEdu <http://www.magedu.com>
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-spring-boot-helloworld
spec:
replicas: 10
strategy:
canary:
steps:
- setWeight: 10
- pause: {}
- setWeight: 20
- pause: {duration: 20}
- setWeight: 30
- pause: {duration: 20}
- setWeight: 40
- pause: {duration: 20}
- setWeight: 60
- pause: {duration: 20}
- setWeight: 80
- pause: {duration: 20}
revisionHistoryLimit: 5
selector:
matchLabels:
app: spring-boot-helloworld
template:
metadata:
labels:
app: spring-boot-helloworld
spec:
containers:
- name: spring-boot-helloworld
image: ikubernetes/spring-boot-helloworld:v0.9.1
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 50m
livenessProbe:
httpGet:
path: '/'
port: 80
scheme: HTTP
initialDelaySeconds: 3
readinessProbe:
httpGet:
path: '/'
port: 80
scheme: HTTP
initialDelaySeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: spring-boot-helloworld
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: spring-boot-helloworld
web界面查看
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
rollouts-spring-boot-helloworld-5dc94d6f9d-24p4p 0/1 ContainerCreating 0 73s
rollouts-spring-boot-helloworld-5dc94d6f9d-4ptkb 0/1 Running 0 72s
rollouts-spring-boot-helloworld-5dc94d6f9d-8qgb2 0/1 ContainerCreating 0 73s
rollouts-spring-boot-helloworld-5dc94d6f9d-9gprm 1/1 Running 0 72s
rollouts-spring-boot-helloworld-5dc94d6f9d-9jbzm 0/1 Running 0 72s
rollouts-spring-boot-helloworld-5dc94d6f9d-fl7tm 0/1 Running 0 73s
rollouts-spring-boot-helloworld-5dc94d6f9d-k8s9h 0/1 ContainerCreating 0 73s
rollouts-spring-boot-helloworld-5dc94d6f9d-lpkgp 0/1 Running 0 73s
rollouts-spring-boot-helloworld-5dc94d6f9d-mgn7q 0/1 Running 0 73s
rollouts-spring-boot-helloworld-5dc94d6f9d-x5drx 0/1 Running 0 73s
[root@master ~]# kubectl get rollouts
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
rollouts-spring-boot-helloworld 10 10 10 3 7m29s
[root@master ~]# kubectl-rollouts list rollouts
NAME STRATEGY STATUS STEP SET-WEIGHT READY DESIRED UP-TO-DATE AVAILABLE
rollouts-spring-boot-helloworld Canary Progressing 12/12 100 5/10 10 10 5
[root@master ~]# kubectl-rollouts get rollouts rollouts-spring-boot-helloworld
Name: rollouts-spring-boot-helloworld
Namespace: default
Status: ✔ Healthy
Strategy: Canary
Step: 12/12
SetWeight: 100
ActualWeight: 100
Images: ikubernetes/spring-boot-helloworld:v0.9.1 (stable)
Replicas:
Desired: 10
Current: 10
Updated: 10
Ready: 10
Available: 10
NAME KIND STATUS AGE INFO
⟳ rollouts-spring-boot-helloworld Rollout ✔ Healthy 8m44s
└──# revision:1
└──⧉ rollouts-spring-boot-helloworld-5dc94d6f9d ReplicaSet ✔ Healthy 8m33s stable
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-24p4p Pod ✔ Running 2m55s ready:1/1,restarts:1
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-8qgb2 Pod ✔ Running 2m55s ready:1/1
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-fl7tm Pod ✔ Running 2m55s ready:1/1,restarts:1
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-k8s9h Pod ✔ Running 2m55s ready:1/1,restarts:2
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-lpkgp Pod ✔ Running 2m55s ready:1/1
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-mgn7q Pod ✔ Running 2m55s ready:1/1,restarts:2
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-x5drx Pod ✔ Running 2m55s ready:1/1,restarts:2
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-4ptkb Pod ✔ Running 2m54s ready:1/1
├──□ rollouts-spring-boot-helloworld-5dc94d6f9d-9gprm Pod ✔ Running 2m54s ready:1/1
└──□ rollouts-spring-boot-helloworld-5dc94d6f9d-9jbzm Pod ✔ Running 2m54s ready:1/1
更新测试
[root@master ~]# kubectl-rollouts get rollouts rollouts-spring-boot-helloworld -w
[root@master ~]# kubectl-rollouts set image rollouts-spring-boot-helloworld spring-boot-helloworld=ikubernetes/spring-boot-helloworld:v0.9.2
rollout "rollouts-spring-boot-helloworld" image updated
可以看到revision:2已经开始更新了
web界面也可以看到已经更新了一个pod
命令行继续更新,会每隔20秒按比例更新
[root@master ~]kubectl get rollouts
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
rollouts-spring-boot-helloworld 10 10 10 10 23h
[root@master ~]# kubectl argo rollouts promote rollouts-spring-boot-helloworld
更新前也可以访问测试下
[root@master ~]# kubectl run client-$RANDOM --image ikubernetes/admin-box:v1.2 --restart=Never -it --rm --command -- /bin/bash
root@client-18539 /# while true; do curl spring-boot-helloworld/version; sleep .5; done
标签:kubectl,rollouts,部署,spring,boot,helloworld,argo From: https://www.cnblogs.com/zyyang1993/p/16884212.html