1.切换root

.关闭centos自带的防火墙

# systemctl disable firewalld

# systemctl stop firewalld 

.安装etcd和kubernetes软件(会自动安装docker)

# yum install -y etcd kubernetes

2.修改两处配置

Docker配置文件/etc/sysconfig/docker, OPTIONS=’–selinux-enabled=false –insecure-registry gcr.io’
Kubernetes apiservce配置文件/etc/kubernetes/apiserver,把–admission_control参数钟的ServiceAccount删除

3.启动所有服务

[root@localhost kubernetes]# systemctl start etcd
[root@localhost kubernetes]# systemctl start docker
[root@localhost kubernetes]# systemctl start kube-apiserver
[root@localhost kubernetes]# systemctl start kube-controller-manager
[root@localhost kubernetes]# systemctl start kube-scheduler
[root@localhost kubernetes]# systemctl start kubelet
[root@localhost kubernetes]# systemctl start kube-proxy

测试,查看

部署nginx服务

[root@localhost kubernetes]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx latest 5699ececb21c Less than a second ago MB
docker.io/ubuntu 16.04 5e8b97a2a082 hours ago MB
hongdada/nginx v3 c5cf58738d6b days ago MB
docker.io/busybox latest 8c811b4aec35 weeks ago 1.15 MB
docker.io/tomcat latest 33e02377a00f weeks ago MB
[root@localhost kubernetes]# kubectl run my-nginx --image=hongdada/nginx:v3 --port=
deployment "my-nginx" created
[root@localhost kubernetes]# kubectl get pod
NAME READY STATUS RESTARTS AGE
my-nginx--q1jvn / ContainerCreating 11s

创建gcr.io/google_containers/pause-amd64:3.0镜像

[root@localhost kubernetes]# docker pull googlecontainer/pause-amd64:3.0
Trying to pull repository docker.io/googlecontainer/pause-amd64 ...
3.0: Pulling from docker.io/googlecontainer/pause-amd64
4f4fb700ef54: Pull complete
ce150f7a21ec: Pull complete
Digest: sha256:f04288efc7e65a84be74d4fc63e235ac3c6c603cf832e442e0bd3f240b10a91b
Status: Downloaded newer image for docker.io/googlecontainer/pause-amd64:3.0
[root@localhost kubernetes]# docker tag googlecontainer/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
[root@localhost kubernetes]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx latest 5699ececb21c Less than a second ago MB
docker.io/ubuntu 16.04 5e8b97a2a082 hours ago MB
hongdada/nginx v3 c5cf58738d6b days ago MB
docker.io/busybox latest 8c811b4aec35 weeks ago 1.15 MB
docker.io/tomcat latest 33e02377a00f weeks ago MB
docker.io/googlecontainer/pause-amd64 3.0 99e59f495ffa years ago kB
gcr.io/google_containers/pause-amd64 3.0 99e59f495ffa years ago kB

kubernetes指令:

# 查看版本
$ kubectl version
Client Version: version.Info{Major:"", Minor:"", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"", Minor:"", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"} # 显示集群信息
$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. # 查看集群中有几个Node
$ kubectl get nodes
NAME STATUS AGE
127.0.0.1 Ready 8m # 运行一个镜像
$ kubectl run my-nginx --image=nginx --replicas= --port=
deployment "my-nginx" created # 查看pod
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-nginx--cwlbb / ContainerCreating 20s
my-nginx--czk6w / Running 20s # 查看服务详情信息
$ kubectl describe pod my-nginx--cwlbb
Name: my-nginx--q1jvn
Namespace: default
Node: 127.0.0.1/127.0.0.1
Start Time: Thu, Jun :: +
Labels: pod-template-hash=
run=my-nginx
Status: Pending
IP:
Controllers: ReplicaSet/my-nginx-
Containers:
my-nginx:
Container ID:
Image: hongdada/nginx:v3
Image ID:
Port: /TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count:
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
2m 2m {default-scheduler } Normal Scheduled Successfully assigned my-nginx--q1jvn to 127.0.0.1
2m 45s {kubelet 127.0.0.1} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)" 1m 3s {kubelet 127.0.0.1} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\"" # 查看已部署
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
my-nginx 3m # 删除pod
$ kubectl delete pod my-nginx--q1jvn
pod "my-nginx-3156591236-q1jvn" deleted # 再次查看pod,发现由于replicas机制,pod又生成一个新的
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-nginx--qm0fq / ContainerCreating 8s # 删除部署的my-nginx服务。彻底删除pod
$ kubectl delete deployment my-nginx
deployment "my-nginx" deleted # 再次查看pod
$ kubectl get pods
No resources found.

对比docker命令:

# docker run
$ docker run -d -e DOMAIN=cluster --name my-nginx -p : nginx
$ kubectl run my-nginx --image=nginx --port= --env="DOMAIN=cluster" # docker ps
$ docker ps
$ kubectl get pods # docker exec
$ docker exec [容器id] ls
$ kubectl exec [pod_id] ls # docker exec 交互式
$ docker exec -it [容器id] /bin/sh
$ kubectl exec -it [pod_id] -- /bin/sh # docker info
$ docker info
$ kubectl cluster-info

yaml文件管理服务:

用yaml文件来创建服务,创建nginx.yaml文件

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: my-nginx
spec:
replicas:
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: hongdada/nginx:v3
ports:
- containerPort:

启动管理服务:

# 根据yaml文件创建服务

$ kubectl create -f nginx.yaml
deployment "my-nginx" created # 查看deployment $ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
my-nginx 17s # 查看Pod $ kubectl get pod
NAME READY STATUS RESTARTS AGE
my-nginx--60v0h / ContainerCreating 9s
my-nginx--pwxfr / ContainerCreating 9s
my-nginx--zlxrn / ContainerCreating 9s # 根据yaml文件删除服务 $ kubectl delete -f nginx.yaml
deployment "my-nginx" deleted $ kubectl get pod
No resources found.
$ kubectl get deployment
No resources found.

Service:

我们创建一个nginx服务

[root@localhost kubernetes]# kubectl run my-nginx --image=hongdada/nginx:v3 --port=
deployment "my-nginx" created
[root@localhost kubernetes]# kubectl expose deployment/my-nginx --type="NodePort" --port
service "my-nginx" exposed
[root@localhost kubernetes]# kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.254.0.1 <none> /TCP 16h
my-nginx 10.254.51.51 <nodes> :/TCP 10s

https://blog.csdn.net/qq_34701586/article/details/78732470

https://www.jianshu.com/p/93f8b074b681

Kubernetes(k8s)入门、单机版安装、kuberctl指令、k8s服务实例的更多相关文章

  1. (1)MySQL(入门操作安装\基本指令)

    什么是MySQL MySQL本质上就是用来管理数据的---用来做增.删.改.查 使用MySQL后管理数据就相对简单方便 数据库软件的种类: 1.什么是关系型数据库(关系型数据库特点就是对数据格式可以有 ...

  2. SuperSocket入门(三)-Telnet多服务实例和服务实例交互配置详解

        在SuperSocket入门(二)中我们已经简单了解了通过配置App.config文件使用BootStrap启动SuperSocket服务.我们先来看一下上个案例中的基本配置文件示例: < ...

  3. 企业运维实践-还不会部署高可用的kubernetes集群?使用kubeadm方式安装高可用k8s集群v1.23.7

    关注「WeiyiGeek」公众号 设为「特别关注」每天带你玩转网络安全运维.应用开发.物联网IOT学习! 希望各位看友[关注.点赞.评论.收藏.投币],助力每一个梦想. 文章目录: 0x00 前言简述 ...

  4. k8s入门系列之扩展组件(一)DNS安装篇

    DNS (domain name system),提供域名解析服务,解决了难于记忆的IP地址问题,以更人性可读可记忆可标识的方式映射对应IP地址. Cluster DNS扩展插件用于支持k8s集群系统 ...

  5. k8s入门系列之集群安装篇

    关于kubernetes组件的详解介绍,请阅读上一篇文章<k8s入门系列之介绍篇> Kubernetes集群安装部署 •Kubernetes集群组件: - etcd 一个高可用的K/V键值 ...

  6. k8s 入门系列之集群安装篇

    关于kubernetes组件的详解介绍,请阅读上一篇文章<k8s入门系列之介绍篇> Kubernetes集群安装部署 •Kubernetes集群组件: - etcd 一个高可用的K/V键值 ...

  7. kubernetes(K8S)快速安装与配置集群搭建图文教程

    kubernetes(K8S)快速安装与配置集群搭建图文教程 作者: admin 分类: K8S 发布时间: 2018-09-16 12:20 Kubernetes是什么? 首先,它是一个全新的基于容 ...

  8. kubernetes系列03—kubeadm安装部署K8S集群

    本文收录在容器技术学习系列文章总目录 1.kubernetes安装介绍 1.1 K8S架构图 1.2 K8S搭建安装示意图 1.3 安装kubernetes方法 1.3.1 方法1:使用kubeadm ...

  9. kubernetes实战(二十五):kubeadm 安装 高可用 k8s v1.13.x

    1.系统环境 使用kubeadm安装高可用k8s v.13.x较为简单,相比以往的版本省去了很多步骤. kubeadm安装高可用k8s v.11 和 v1.12 点我 主机信息 主机名 IP地址 说明 ...

  10. K8s集群安装--最新版 Kubernetes 1.14.1

    K8s集群安装--最新版 Kubernetes 1.14.1 前言 网上有很多关于k8s安装的文章,但是我参照一些文章安装时碰到了不少坑.今天终于安装好了,故将一些关键点写下来与大家共享. 我安装是基 ...

随机推荐

  1. Chrome 扩展

    http://www.cnblogs.com/coco1s/p/8004510.html

  2. QT自定义消息

    1.派生QAbstractNativeEventFilter,重写nativeEventFilter()函数 #ifndef CMYMESSAGEHANDLER_H #define CMYMESSAG ...

  3. python 可视化

    一.环境安装 windows:pip install numpy scipy matplotlib #pip install http://effbot.org/downloads/Imaging-1 ...

  4. 在lua中从一个字符串中移除空间源码

    /* trim.c - based on http://lua-users.org/lists/lua-l/2009-12/msg00951.html from Sean Conner */ #inc ...

  5. 【Hadoop学习之十一】MapReduce案例分析三-PageRank

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-3.1.1 什么是pagerank?算法原理- ...

  6. java 泛型E T ?的区别

    Java泛型中的标记符含义:  E - Element (在集合中使用,因为集合中存放的是元素) T - Type(Java 类) K - Key(键) V - Value(值) N - Number ...

  7. 如何用nginx在本地把9000端口转发到80端口上

    起因看到一个用java写的轻博客,于是就兴致冲冲的试用一下.由于是lnmp的环境,Nginx占用了80端口,新博客只能用其他的端口,这里选择了9000端口,本地测试没问题.总不能访问了域名然后在加上端 ...

  8. 前端框架VUE----cli脚手架(框架)

    一.创建vue项目 npm install vue-cli -g #-g全局 (sudo)npm install vue-cli -g #mac笔记本 vue-init webpack myvue # ...

  9. LINUX搭建PySpider爬虫服务

    1.环境搭建 yum update -y yum install gcc gcc-c++ -y yum install python-pip python-devel python-distribut ...

  10. VisualSVN Server 服务器搭建 和 TortoiseSVN的配置和使用方法

    摘自:https://blog.csdn.net/litaoshoujiao/article/details/8526136 一.VisualSVN Server的配置和使用方法[服务器端] 安装好V ...