Nuwa 中文

Introduction
Since the native Deployment and Statefulset provides basic publishing strategies that cannot meet our scenario, in some cases it does not support cross-computer room publishing, batch publishing by group, and Deployment does not support step control, etc., so our nuwa project as the data plane of our cloud platform, the project supports stateful resources (stone) and stateless resources (water), and has dynamic resource injection (injector).
Features
- Multi-Zone deployment, can be specific to a machine in a rack in a zone.
- Delicate deployment strategy.
- Deploy by group, batch deployment.
- Blue-green deployment, canary deployment.
- Stateful and stateless deployment.
- Dynamic injection.
Water Resource
Advanced implementation of Deployment based on kubernetes native resource
- Supports geographical location deployment, which can be specific to a machine in a rack in a zone.
- Support delicate deployment strategy: Alpha, beta, release.
Deployment Strategy
This deployment strategy occurs because the released Pod itself is wrong (such as a program startup error due to lack of configuration). If a large number of releases will cause machine jitter and affect the running of the running Pod, reduce the jitter as much as possible. Lowest, let the user confirm whether the first pod released is wrong, and confirm that the next pod will be released.
- Alpha: Find a node randomly and only deploy a Pod, waiting for the user to confirm whether there is an error.
- Beta: Pods are deployed on each Node.
- Release: Full deployment.
Water resource usage template
apiVersion: nuwa.nip.io/v1
kind: Water
metadata:
name: water-sample
spec:
strategy: Release
template:
metadata:
name: water-sample
labels:
app: water-sample
spec:
containers:
- name: cn-0
image: nginx:latest
imagePullPolicy: IfNotPresent
service:
ports:
- name: default-web-port
protocol: TCP
port: 80
targetPort: 80
type: NodePort
coordinates:
- zone: A
rack: W-01
host: node2
replicas: 1
- zone: A
rack: S-02
host: node3
replicas: 1
- zone: B
rack: W-01
host: node4
replicas: 1
- zone: B
rack: S-02
host: node5
replicas: 1
Stone resource
Advanced implementation of Statefulset based on kubernetes native resource
- Supports geo-location publishing, which can be specific to a machine in a rack in a zone.
- Support deployment strategy by group: Alpha, Beta, Omega, Release release(
because of the need to mount the disk).
Deployment Strategy
- Alpha: Pick one of the groups and publish 1 Pod
- Beta: Pick one (multi-group / one-group) to publish 1 Pod
- Omega: Pick multiple groups and publish 1 Pod on each machine
- Release: Full release
Stone resource usage template
apiVersion: nuwa.nip.io/v1
kind: Stone
metadata:
name: stone-example
spec:
strategy: Release
template:
metadata:
name: sample
labels:
app: stone-example
spec:
containers:
- name: cn-0
image: nginx:alpine
imagePullPolicy: IfNotPresent
service:
ports:
- name: default-web-port
protocol: TCP
port: 80
targetPort: 80
type: NodePort
coordinates:
- group: A
replicas: 3
zoneset:
- zone: A
rack: W-01
host: node2
- zone: A
rack: S-02
host: node3
- group: B
replicas: 2
zoneset:
- zone: B
rack: W-01
host: node4
- zone: B
rack: S-02
host: node5
Injector resource
The implementation of the Injector resource combined with the CRD + Sidecar, which is to allow users to dynamically inject log collection, configuration files, and tracking agent injection. Supports injection before and after the business container, combined with Water resource and Stone resource. When Water is deleted, the corresponding Injector resource will also be GC.
With the use of Water resources
apiVersion: nuwa.nip.io/v1
kind: Water
metadata:
name: water-sample
spec:
strategy: Release
template:
metadata:
name: sample
labels:
app: water-sample
spec:
containers:
- name: cn-0
image: nginx:latest
imagePullPolicy: IfNotPresent
service:
ports:
- name: default-web-port
protocol: TCP
port: 80
targetPort: 80
type: NodePort
coordinates:
- zone: A
rack: W-01
host: node2
replicas: 2
- zone: A
rack: S-02
host: node3
replicas: 0
- zone: B
rack: W-01
host: node4
replicas: 0
- zone: B
rack: S-02
host: node5
replicas: 0
---
# Injector intercepting the above resources will be injected into a busybox container before the business container
apiVersion: nuwa.nip.io/v1
kind: Injector
metadata:
name: water-sample
spec:
namespace: ${CURRENT_NAMESPACE}
name: water-sample
resourceType: Water
selector:
matchLabels:
app: water-sample
preContainers:
- name: count
image: busybox
args:
- /bin/sh
- -c
- >
i=0;
while true;
do
echo "$i: $(date)" >> /var/log/1.log;
echo "$(date) INFO $i" >> /var/log/2.log;
i=$((i+1));
sleep 1;
done
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
emptyDir: {}
Installation requirements
- Requires kubernetes cluster version greater than or equal to 1.15.x
Label the machine
kubectl label nodes node2 nuwa.io/zone=A nuwa.io/rack=W-01 nuwa.io/host=node2 --overwrite
kubectl label nodes node3 nuwa.io/zone=A nuwa.io/rack=S-02 nuwa.io/host=node3 --overwrite
kubectl label nodes node4 nuwa.io/zone=B nuwa.io/rack=W-01 nuwa.io/host=node4 --overwrite
kubectl label nodes node5 nuwa.io/zone=B nuwa.io/rack=S-02 nuwa.io/host=node5 --overwrite
Install Nuwa CRD resource
kubectl apply -f https://github.com/yametech/nuwa/releases/download/${VERSION}/nuwa.yaml