k8s部署测试实例
查看运行中pod,并运行一个容器
[root@mast-1 k8s]# kubectl get pods
No resources found.
[root@mast-1 k8s]# kubectl run nginx --image=nginx 运行nginx容器
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed i
n a future version. Use kubectl create instead.deployment.apps/nginx created
[root@mast-1 k8s]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-dbddb74b8-h59k2 0/1 ContainerCreating 0 3s
[root@mast-1 k8s]# kubectl get all 查看运行所有的资源
NAME READY STATUS RESTARTS AGE
pod/nginx-dbddb74b8-h59k2 1/1 Running 0 85s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 8h NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1 1 1 1 86s NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-dbddb74b8 1 1 1 86s
[root@mast-1 k8s]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 8h
nginx NodePort 10.0.0.82 <none> 80:31330/TCP 103s
两个节点访问同一个容器
[root@node-1 kubernetes]# curl 10.0.0.82:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@node-2 cfg]# curl 10.0.0.82:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
浏览器里访问两个node任意的IP:31330端口

master 节点查看日志,报错并解决
[root@mast-1 k8s]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-dbddb74b8-h59k2 1/1 Running 2 33m
[root@mast-1 k8s]# kubectl logs nginx-dbddb74b8-h59k2
error: You must be logged in to the server (the server has asked for the client to provide credentials ( pods/log nginx-dbddb74b8-h59k2))
[root@node-1 kubernetes]# cat cfg/kubelet.config kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
address: 192.168.10.13
port: 10250
cgroupDriver: cgroupfs
clusterDNS:
- 10.0.0.2
clusterDomain: cluster.local.
failSwapOn: false
--------------添加下面参数-----
authentication:
anonymous:
enabled: true
[root@node-2 cfg]# vi kubelet.config kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
address: 192.168.10.14
port: 10250
cgroupDriver: cgroupfs
clusterDNS:
- 10.0.0.2
clusterDomain: cluster.local.
failSwapOn: false
----------------------------
authentication:
anonymous:
enabled: true
重启
[root@node-1 kubernetes]# systemctl restart kubelet.service
[root@node-2 cfg]# systemctl restart kubelet.service
[root@mast-1 k8s]# kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous
clusterrolebinding.rbac.authorization.k8s.io/cluster-system-anonymous created
[root@mast-1 k8s]# kubectl logs nginx-dbddb74b8-h59k2
10.0.0.82 - - [23/Apr/2019:09:59:53 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
10.0.0.82 - - [23/Apr/2019:10:02:55 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
172.17.82.0 - - [23/Apr/2019:10:03:11 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
172.17.8.1 - - [23/Apr/2019:10:06:41 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.0 Safari/537.36" "-"
2019/04/23 10:06:49 [error] 6#6: *4 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.8.1, server: localhost, request: "GET /favicon.ico HTTP/1.
1", host: "192.168.10.13:31330", referrer: "http://192.168.10.13:31330/"172.17.8.1 - - [23/Apr/2019:10:06:49 +0000] "GET /favicon.ico HTTP/1.1" 404 556 "http://192.168.10.13:31330/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrom
e/71.0.3554.0 Safari/537.36" "-"
动态查看
[root@mast-1 k8s]# kubectl logs nginx-dbddb74b8-h59k2 -f
10.0.0.82 - - [23/Apr/2019:09:59:53 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
10.0.0.82 - - [23/Apr/2019:10:02:55 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
172.17.82.0 - - [23/Apr/2019:10:03:11 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
172.17.8.1 - - [23/Apr/2019:10:06:41 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.0 Safari/537.36" "-"
2019/04/23 10:06:49 [error] 6#6: *4 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.8.1, server: localhost, request: "GET /favicon.ico HTTP/1.
1", host: "192.168.10.13:31330", referrer: "http://192.168.10.13:31330/"172.17.8.1 - - [23/Apr/2019:10:06:49 +0000] "GET /favicon.ico HTTP/1.1" 404 556 "http://192.168.10.13:31330/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrom
e/71.0.3554.0 Safari/537.36" "-"
k8s部署测试实例的更多相关文章
- 微服务架构 - 离线部署k8s平台并部署测试实例
一般在公司部署或者真实环境部署k8s平台,很有可能是内网环境,也即意味着是无法连接互联网的环境,这时就需要离线部署k8s平台.在此整理离线部署k8s的步骤,分享给大家,有什么不足之处,欢迎指正. 1. ...
- Python服务Dokcer化并k8s部署实例
这篇文章记录了我试验将一个基于python的服务docker化并k8s部署的过程. 服务介绍Docker化设计业务代码改造创建docker镜像K8S部署设计yaml文件运行服务介绍这是一个用 pyth ...
- 拥抱云原生,如何将开源项目用k8s部署?
微信搜索[阿丸笔记],关注Java/MySQL/中间件各系列原创实战笔记,干货满满. k8s以及云原生相关概念近年来一直比较火热,阿丸最近搞了个相关项目,小结一下. 本文将重点分享阿里开源项目otte ...
- AWS EKS 创建k8s生产环境实例
#AWS EKS 创建k8s生产环境实例 在AWS部署海外节点, 图简单使用web控制台创建VPC和k8s集群出错(k8s), 使用cli命令行工具创建成功 本实例为复盘, 记录aws命令行工具创建e ...
- Prometheus K8S部署
Prometheus K8S部署 部署方式:https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/prometheus ...
- k8s 部署 Java 项目
前几天安装了 k8s 并测试了自动伸缩功能(HPA),今天来部署一个简单的 Java 应用到 k8s. 开始之前需要先安装一下 ingress 插件.ingress 作为 k8s 的流量入口,有多种实 ...
- 日志分析系统 - k8s部署ElasticSearch集群
K8s部署ElasticSearch集群 1.前提准备工作 1.1 创建elastic的命名空间 namespace编排文件如下: elastic.namespace.yaml --- apiVers ...
- K8s 部署 Dashboard UI 仪表板 ——让一切可视化
K8s 部署 Dashboard UI 仪表板 --让一切可视化 Dashboard 介绍 仪表板是基于Web的Kubernetes用户界面.您可以使用仪表板将容器化应用程序部署到Kuberne ...
- 微服务从代码到k8s部署应有尽有系列(九、事务精讲)
我们用一个系列来讲解从需求到上线.从代码到k8s部署.从日志到监控等各个方面的微服务完整实践. 整个项目使用了go-zero开发的微服务,基本包含了go-zero以及相关go-zero作者开发的一些中 ...
随机推荐
- phpstorm 10 初体验
一:安装phpstorm 10 去phpstorm 10官网下载,安装 https://www.jetbrains.com/phpstorm/ 按照提示安装,最后注册步骤,选择“License ser ...
- Codechef QGRID
QGRID code 给定一个 n × m(1 <= m <= 3) 的点网格,网格的边上以及点上都有权值.初始时所有点的权值都为 0 .维护两种操作:1. x1 y1 x2 y2 c 把 ...
- Moctf--Pubg题目
假期举办的一场比赛,开始的题目比较基础,misc神马的都还好说,就是web有些坑了,比如我今天要写的这一道题目.不过大佬说很简单..不过最后我还是解出来了,把思路放在这里. 打开之后得到这个页面,在网 ...
- csacademy Round #36(模拟+最坏情况)
传送门 题意 给出n种袜子,每种袜子个数a[i],两只相同种类袜子配成一对,询问至少拿出多少只袜子能确保配出k对袜子 分析 In order to find out the minimum numbe ...
- Codeforces 702B【二分】
题意: 给一个a数组,输出有多少对相加是等于2^x的.1<=a[i]<=1e9,n<=1e5 思路: a[i]+a[j]=2^x 对于每个a[i],枚举x,然后二分查找a[j]; p ...
- hihoCoder搜索二·骑士问题
#include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> ...
- Java 在线反编译
使用jd-gui反编译java提示 // INTERNAL ERROR // 的类,用在线反编译直接反编译.class http://www.showmycode.com/
- 编译boost asio http/server 方法
这段时间学习boost 的asio 编程,想编译asio自带的http/server的程序,无奈在网上根本找不到方法,只能自己摸索学习. 登陆boost asio 的example 目录,(我 boo ...
- 决斗(Headshot )
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; char ...
- css为什么要定最小宽度和最大宽度,最小宽度和最大宽度有什么用
设最小和最大宽度,主要是为了防止页面变形而已如,如果一个页面的宽度设置为百分比,这时此页面的宽度会根据浏览器的宽度而定但如果浏览器的宽度过小,页面就会变形,例如,你做的用百分比设置的页面,而用户端的浏 ...