Kubenete study notes (Replication Controller)

Replication controller:

ReplicationController schedules pod to one work node, kubelet application in node pulls image and create containers.
Pod started by “kubectl run” is not created directly. ReplicationController is created by command and replicationController creates pod
Create pod: kubectl run [replication controller name] --image=[image name] --port=[port number] --generator=run/v1. Without --generate flag, it creates deployment instead of replicationController
Replication controller is able to scale number of pods: kubectl scale rc [replication controller] --replicas=3
Replication controller ensures number of pods by label selector matches desired number (replica count), if not, it starts new pod or delete existing pod
Pods started by replication controller via kubectl run command can not be deleted, a new pod will be bring up, need to delete replication controller

Defining liveness probe allow

spec:
  containers:
    livenessProbe:
      httpGet:
        path: /
        port: 8080

Spec/containers/livenessProbe/initialDelaySeconds is important to ensure initial start up success before sending first liveness probe request

Troubleshoot pod failure:
kubectl describe po [podname] Last state and events can show previous pod problem
kubectl logs [pod name] --previous shows log of previous crashed pod

Define good liveness probe:

  • Use /health endpoint
  • Keep probe lightweight
  • No retry loop in probe is required

Replication controller definition contains pod template:

spec:
  template:
    metadata:
      labels:
        app: kubia
    spec:
      containers:
        - name: kubia
          image: luksa/kubia
          ports:
            - containerPort: 8080 

Don’t specify a pod selector when defining a ReplicationController. Let Kubernetes extract it from the pod template, if replicationController’s label selector does not match pod template, kubernetes api server will report error
Changes to replication controller’s label selector and the pod template have no effect on existing pods.
By changing a pod’s labels, it can be removed from or added to the scope of a ReplicationController. It can even be moved from one ReplicationController to
another.
Pod’s metadata.ownerReferences shows replication controller information

Compare replication set(apiVersion: apps/v1beta2 kind: ReplicaSet) and replication controller:
Selector expression under in selector.matchLabels for replication set
Support a rich set of selector expression like ‘IN’, ‘NOT IN’, ‘EXISTS’, ‘DOES NOT EXIST’

DaemonSet: (apiVersion: apps/v1beta2 kind: DaemonSet)
Use DaemonSet to start exactly one pod on each node
Used for common services like log collector etc
Auto adapt to node addition and create pod
No replication count required
Can specify node-selector to deploy pods to a subset of nodes
Deploying pods via daemonset bypasses kubenetes scheduler

JobResource: (apiVersion: batch/v1 kind: Job )
Used for run-once adhoc task
Set spec: restartPolicy: OnFailure/Never for handling job execution failure
Set spec: completions: 5 (number of execution) parallelism: 2 (number of parallel nodes) to allow multiple times and parallel execution of job
Set spec:activeDeadlineSeconds to terminate long run job. Set spec:backoffLimit for number of retries before marking job as fail

Cronjob: (apiVersion: batch/v1beta1 kind: CronJob)
Set spec: schedule: "0,15,30,45 "

原文地址:https://blog.51cto.com/shadowisper/2476298

时间: 2024-10-11 13:30:18

Kubenete study notes (Replication Controller)的相关文章

Kubenete study notes (Service)

Service: Ways to create service:Kubectl expose created a Service resource with the same pod selector as the one used by the ReplicationControllerKubectl create with service specs apiVersion: v1 kind: Service metadata: name: kubia spec: ports: - port:

Kubenete study notes (POD)

Pod Definition: Create pod by definition: kubectl create -f [filename]Display pod definition: kubectl get po [pod name] -o yaml/jsonGetting log: kubectl logs [pod name] -c [container name] Port forwarding: kubectl port-forward [pod name] [localport]:

My study notes —— 初始24种设计模式

摘要 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代码可靠性. 毫无疑问,设计模式于己于他人于系统都是多赢的:设计模式使代码编制真正工程化:设计模式是软件工程的基石脉络,如同大厦的结构一样. 目录 设计概念 设计原则 四要素 基本模式 创建型 结构型 行为型 正文 设计概念 Change:让代码富有弹性,能够应对需求的变化: DRY:消除冗余,让代码更精炼: KISS:让代码

[2016-03-16]How can I take better study notes?

A:Dad,how can I take better study notes? B:Okay,look.Divide your pate into two columns. A:Like this? B:No.the one on the right should be larger. A:Let me do it agian.Is this better? B:Yes.Write down all the ideas on the right side of the page. A:What

Machine Learning Algorithms Study Notes(3)--Learning Theory

Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 229 的学习笔记. Machine Learning Algorithms Study Notes 系列文章介绍 3 Learning Theory 3.1 Regularization and model selection 模型选择问题:对于一个学习问题,可以有多种模型选择.比如要拟合一组样本点,

Machine Learning Algorithms Study Notes(2)--Supervised Learning

Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 2    Supervised Learning    3 2.1    Perceptron Learning Algorithm (PLA)    3 2.1.1    PLA -- "知错能改"演算法    4 2.2    Linear Regression    6 2.2.1    线性回归模型    6 2.2.2    最小二乘法( le

Machine Learning Algorithms Study Notes(1)--Introduction

Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 目 录 1    Introduction    1 1.1    What is Machine Learning    1 1.2    学习心得和笔记的框架    1 2    Supervised Learning    3 2.1    Perceptron Learning Algorithm (PLA)    3 2.1.1    PLA -- "知

Kubernetes基本概念和术语之Lable和Replication Controller

1.Kubernetes之Lable标签 Lable是kubernetes中的一个核心概念,一个lable是一个key=value的键值对,key与value由用户自己指定,lable可以附加到各种资源对象上,例如Node.Pod.Service.RC等,一个资源对象可以定义任意数量的Lable,同一个Lable也可以被添加到任意数量的资源对象上去,Lable通常在资源对象定义时确定,也可以在对象创建后动态添加或者删除. 可以通过给一个资源对象绑定一个或多个不同的Lable来实现多维度的资源分组

ORACLE STUDY NOTES 04

? [JSU]LJDragon's Oracle course notes In the first semester, junior year ? PL/SQL游标(declare .. begin .. end) --游标:指向查询结果集的指针,指针指向哪一行,提取的就是哪一行的数据 --PLSQL的游标默认指向结果集的第1行 --显示游标的四大步骤: 1.定义游标 cursor 游标变量名 is 查询语句; 2.打开游标 open 游标变量名;(可以重复打开) 3.提取游标 fetch 游