Rancher deployment and expansion of Kubernetes cluster Basic chapter II

Source: Internet
Author: User
Tags allkeys

The next one is to deploy and expand the Kubernetes cluster based on rancher


7. Configuring Redis with Configmap

Https://github.com/kubernetes/kubernetes.github.io/blob/master/docs/user-guide/configmap/redis/redis-config


Redis-config

MaxMemory 2MB Maxmemory-policy Allkeys-lru
# kubectl Create Configmap example-redis-config--from-file=./redis-config


# Kubectl Get configmap example-redis-config-o yamlapiversion:v1data:redis-config: | MaxMemory 2mb maxmemory-policy allkeys-lrukind:configmapmetadata:creationtimestamp:2017-07-12t13:27:56z name:exam Ple-redis-config namespace:default resourceversion: "45707" Selflink:/api/v1/namespaces/default/configmaps/ Example-redis-config uid:eab522fd-6705-11e7-94da-02672b869d7f


Redis-pod.yaml

apiversion: v1kind: podmetadata:  name: redisspec:  containers:   - name: redis    image: kubernetes/redis:v1    env:     - name: MASTER      value:  "true"      ports:    - containerPort: 6379     RESOURCES:      LIMITS:        CPU:   "0.1"     volumemounts:    - mountpath: / Redis-master-data      name: data    - mountpath:  /redis-master      name: config  volumes:     - name: data      emptydir: {}    -  name: config      configMap:        name: example-redis-config         items:        - key:  redis-config          path: redis.conf



# Kubectl create-f redis-pod.yaml pod "Redis" created


# kubectl exec-it redis redis-cli127.0.0.1:6379> 127.0.0.1:6379> 127.0.0.1:6379> config get maxmemory1) "Maxmem Ory "2)" 2097152 "127.0.0.1:6379> config get maxmemory-policy1)" Maxmemory-policy "2)" Allkeys-lru "127.0.0.1:6379 >

8. Managing Kubernetes objects with the KUBECTL command


# kubectl Run Nginx--image nginxdeployment "Nginx" created


Or

# kubectl Create deployment Nginx--image Nginx


Creating an object defined in a configuration file using Kubectl Create

#kubectl create-f Nginx.yaml

Delete objects defined in two configuration files

#kubectl delete-f nginx.yaml-f Redis.yaml

 

Updating objects


#kubectl replace-f Nginx.yaml

Process all object profiles under the Configs directory, create new objects or patch existing objects

#kubectl apply-f configs/

Recursive processing of object configuration files under subdirectories

#kubectl Apply-r-F configs/

9. Deploy stateless Apps

9.1 Running a stateless application with deployment

Deployment.yaml

apiversion: apps/v1beta1kind: deploymentmetadata:  name: nginx-deploymentspec:   replicas: 2 # tells deployment to run 2 pods matching  the template  template: # create pods using pod definition  In this template    metadata:      # unlike  pod-nginx.yaml, the name is not included in the meta data  as a unique name is      # generated from  the deployment name      labels:         app: nginx    spec:      containers:       - name: nginx         Image: nginx:1.7.9        ports:        -  Containerport: 80


Kubectl create-f Https://k8s.io/docs/tasks/run-application/deployment.yaml


It is important to note that rancher1.6.2 deploys kubernetes 1.5.4


The apiversion here should be changed to extensions/v1beta1 .

Kubernetes introduced apps/v1beta1 from 1.6. Deployment replaces Extensions/v1beta1. Deployment

To display this deployment information

# Kubectl Describe deployment nginx-deployment















10. Deploying Stateful applications











This article is from the Linux SA John blog, so be sure to keep this source http://john88wang.blog.51cto.com/2165294/1946903

Rancher deployment and expansion of Kubernetes cluster Basic chapter II

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.