kubernetes cluster orchestration – k8s storage (volumes, persistent volumes, statefulset controller)

volumes emptyDir volume vim emptydir.yaml apiVersion: v1 Kind: Pod metadata: name: vol1 spec: containers: – image: busyboxplus name: vm1 command: [“sleep”, “300”] volumeMounts: – mountPath: /cache name: cache-volume – name: vm2 image: nginx volumeMounts: – mountPath: /usr/share/nginx/html name: cache-volume volumes: – name: cache-volume emptyDir: medium: Memory sizeLimit: 100Mi kubectl apply -f emptydir.yaml kubectl get pod […]

[Apache Flink] Implementing stateful functions

Article directory Declare key-value partitioning status in RuntimeContext Implement the operator list status through the ListCheckPonitend interface Using the CheckpointedFunction interface Receive checkpoint completion notification Reference documentation Declare key-value partition status in RuntimeContext Flink provides several different primitives (data types) for keyed state. This is because different algorithms and operations may need to manage different […]

Stateful and stateless services in Kubernetes

Author:rab Directory Preface 1. Stateless service case 1.1 yml case 1.2 Expansion and reduction 1.2.1 Expansion 1.2.2 Shrinking 1.3 Pause and resume 1.3.1 Pause 1.3.2 Recovery 1.4 Rollback 2. Stateful service cases 2.1 yml case 2.2 Expansion and reduction 2.2.1 Capacity expansion 2.2.2 Shrinking Summarize Foreword In Kubernetes (k8s), stateful services and stateless services are […]

Kubernetes Statefulset

Understanding stateful workload requirements A stateful workload is a piece of software that must store and maintain state in order to function. This state must be maintained when the workload is restarted or relocated. This makes stateful workloads much more difficult to operate. Stateful workloads are also much harder to scale because you can’t simply […]

Flutter view principle StatefulWidget, InheritedWidget

Directory StatefulElement 1.Constructor 2.build 3._firstBuild 3.didChangeDependencies 4.setState InheritedElement 1.Elementclass 2._updateInheritance 3.InheritedWidgetdataispasseddownward 3.1dependOnInheritedWidgetOfExactType 4.StatebindingofInheritedWidget 4.1.ProxyElement Intheflutterproject,StatelessWidget,StatefulWidget,andInheritedWidgetarecommonwidgets.Today,wewillanalyzehowtheyareimplementedthroughthesourcecode. Thecorrespondingfunctionsarebasicallyimplementedinelements,andwidgetsonlyprovidecomponentconfiguration.Therefore,whenexplainingStatefulWidgetandInheritedWidget,wemainlyanalyzetheimplementationofthecorrespondingelements. StatefulElement StatefulWidgetisaWidgetwithstate.UnlikestatelessWidget,thecreationofWidgetisdelegatedtostateinsteadofbeingcreateddirectlyusingwidget.build.ThepreviouschapterofStatelessWidgetcodehasalreadytalkedabouttheestablishmentprocessofthreetrees,soignoreit. )) 1.Constructor ComparetheconstructorofstatelessElement: classStatefulElementextendsComponentElement{<!—-> ///Createsanelementthatusesthegivenwidgetasitsconfiguration. StatefulElement(StatefulWidgetwidget) :_state=widget.createState(), super(widget){<!—-> assert(state._element==null); state._element=this; state._widget=widget; assert(state._debugLifecycleState==_StateLifecycle.created); } //…omitted } Intheconstructor,widget.createState()iscalleddirectly.Anewstateiscreated.Themembervariablesofstateincludeelement,andwidgetsareallprivatemembers.Atthistime,thelifecycleofstateshouldbecreated,state._debugLifecycleState==_StateLifecycle.created 2.build Usestatetocreatewidgets: Widgetbuild()=>state.build(this); 3._firstBuild void_firstBuild(){<!—-> //…omitted state.didChangeDependencies(); assert((){<!—-> state._debugLifecycleState=_StateLifecycle.ready; }()); super._firstBuild(); } Thisfunctioncalloccurswhenanelementisgeneratedforthefirsttime.Itistriggeredwhentheelementismounted.Atthistime,thestate’sdidChangeDependenciesmethodwillbecalledback.AnothersituationisthattheremaybeacallbackduringperformRebuild(),whichwillbediscussedbelow. Lookatthispictureagain: 3.didChangeDependencies ThedidChangeDependenciesfunctionisthecallbackinterfaceofelement.Thisinterfaceiscalledbyparentnotificationwhendependencieschange.Itwillmodify_didChangeDependencies=true;,andthentheperformRebuild()functionwilltriggerstate.didChangeDependencies.();‘scallback. bool_didChangeDependencies=false; @override voiddidChangeDependencies(){<!—-> super.didChangeDependencies(); _didChangeDependencies=true; […]

[kubernetes] Use of StatefulSet in kubernetes

Directory 1 Why you need StatefulSet 2 Key fields of Yaml of StatefulSet 3. Handling of failed expansion and contraction 4 partition rolling update 5 Summary 1 Why StatefulSet is needed Conventional applications usually use Deployment, and if they need to be deployed on all machines, use DaemonSet. However, there is a type of application […]

k8s statefulSet controller-network identification

k8s-statefulSet controller-network identification 1. k8s-statefulSet controller-network identification Stable network identity: Use Headless Service (compared to ordinary Service, which only defines spec.clusterIP as None) to maintain the Pod network identity. Each Pod will be assigned a numerical number and deployed in numerical order. You also need to add the serviceName: “nginx” field to the StatefulSet to […]

Kubernetes cluster implements application canary release through StatefulSet

Kubernetes cluster implements application canary release through StatefulSet The name of Canary Release comes from the historical practice of “canary in coal mine”. In the early 20th century, miners carried canaries into coal mines and used them as an early warning system for toxic gases. Canaries are more sensitive to toxic gases, such as carbon […]

k8s-storage-pv and pvc and StatefulSet

k8s-storage-pv and pvc and StatefulSet One concept 1.1 pv PersistentVolume (PV) Is storage set up by an administrator and is part of a cluster. Just like nodes are resources in the cluster, PVs are also resources in the cluster. PV is a volume plug-in like Volume, but has a life cycle independent of the Pod […]

k8s StatefulSet controller-independent storage

k8s-StatefulSet controller-independent storage 1. StatefulSet controller-independent storage Exclusive storage: The storage volume of StatefulSet is created using VolumeClaimTemplate, which is called the volume application template. When StatefulSet uses VolumeClaimTemplate to create a PersistentVolume, a numbered PVC will also be allocated and created for each Pod. Each PVC is bound to the corresponding PV to ensure […]