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作者开发的一些中 ...
随机推荐
- 在msys里进行复制和粘贴操作
You can copy text from an MSYS window to the clipboard simply by selecting the text you want to copy ...
- HTTP node静态资源请求加载demo
MIME type的缩写为(Multipurpose Internet Mail Extensions)代表互联网媒体类型(Internet media type),MIME使用一个简单的字符串组成, ...
- 使用AES128加密字符串
import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.apache.c ...
- eclipse与maven配置
一.配置maven环境 电脑上需安装java环境,安装JDK1.7 + 版本 (将JAVA_HOME/bin 配置环境变量path ) 配置 MAVEN_HOME 将 %MAVEN_HOME%/bin ...
- 任务22:课程介绍 & 任务23:Http请求的处理过程
任务23:Http请求的处理过程 http的处理过程 用户输入一个地址
- Eclipse中,Open Type(Ctrl+Shift+T)失效后做法。
好几天ctrl shift T都不好用了,一直认为是工程的问题,没太在意,反正ctrl shift R也可也,今天看同事的好用,于是到网上查了一下解决的方法,刚才试了一下,应该是这个问题,明天就去公司 ...
- 探究final在java中的作用
目录 一. final修饰变量 1. 基础: final修饰基本数据类型变量和引用数据类型变量. 2. 进阶: 被final修饰的常量在编译阶段会被放入常量池中 3. 探索: 为什么局部/匿名内部类在 ...
- 用纯XMLHttpRequest实现AJAX
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- hdu3938 Portal 离线+并查集
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int ...
- js、css外部文件的相对路径问题
如果js.css外部文件有使用到相对路径时,需要注意其相对路径的基准是不一样的. 比如说,在index.html中引用到了外部的js和css文件,这两个文件都通过相对路径引用了某一张图片:这些文件所在 ...