当前位置: 首页 > news >正文

Kubernetes 安装 Nginx以及配置自动补全

部署 Nginx :

[root@k8s-master ~]# kubectl create deployment nginx --image=nginx:1.14-alpine
deployment.apps/nginx created

暴露端口:

[root@k8s-master ~]# kubectl expose deployment nginx --port=80 --type=NodePort
service/nginx exposed

查看服务状态:

[root@k8s-master ~]# kubectl get pods,svc
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-65c4bffcb6-f9b55   1/1     Running   0          61sNAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
service/kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        45h
service/nginx        NodePort    10.96.67.225   <none>        80:31339/TCP   16s[root@k8s-master ~]# kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
nginx-65c4bffcb6-f9b55   1/1     Running   0          3m17s
[root@k8s-master ~]# kubectl get service
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        45h
nginx        NodePort    10.96.67.225   <none>        80:31339/TCP   2m39s

使用master主节点ip地址访问nginx:

 

 使用集群IP访问:

[root@k8s-master ~]# kubectl get pods,svc
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-65c4bffcb6-f9b55   1/1     Running   0          61sNAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
service/kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        45h
service/nginx        NodePort    10.96.67.225   <none>        80:31339/TCP   16s
[root@k8s-master ~]# curl -X GET 10.96.67.225
<!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>

自动补全:

# 安装 
yum -y install bash-completion# 自动补全 
echo 'source <(kubectl completion bash)' >>~/.bashrc 
kubectl completion bash >/etc/bash_completion.d/kubectl
# 全局
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
source /usr/share/bash-completion/bash_completion

http://www.lryc.cn/news/510776.html

相关文章:

  • CSS---实现盒元素div内input/textarea的focus状态时给父元素加属性!
  • jmeter设置tps、响应时间监测时间间隔
  • WPSJS:让 WPS 办公与 JavaScript 完美联动
  • 深度学习与图像处理(国产深度学习框架——飞桨官方指定教材)
  • taiwindcss
  • 信号的时域截断——频谱泄漏——光晕效应
  • 【Linux编程】TcpServer 类的设计与实现:构建高性能的 TCP 服务器(二)
  • Mono里运行C#脚本8—mono_image_storage_open打开EXE文件
  • XMLHttpRequest的基础知识
  • 力扣矩阵-算法模版总结
  • 如何在短时间内读懂复杂的英文文献?
  • 基于aspose.words组件的word bytes转pdf bytes,去除水印和解决linux中文乱码问题
  • Bert中文文本分类
  • 【深度学习】Java DL4J基于 CNN 构建车辆识别与跟踪模型
  • 【C#】C#打印当前时间以及TimeSpan()介绍
  • 【Linux 网络 (五)】Tcp/Udp协议
  • 多旋翼无人机理论 | 四旋翼动力学数学模型与Matlab仿真
  • Vue3项目中引入TailwindCSS(图文详情)
  • 【开源项目】数字孪生化工厂—开源工程及源码
  • 咨询团队如何通过轻量型工具优化项目管理和提高团队协作效率?
  • javaWeb开发
  • 如何在 Vue 中处理 API 请求?
  • 基于Debian的Linux发行版的包管理工具
  • 2022年国家公考《申论》题(行政执法)
  • 贪心算法(常见贪心模型)
  • git自动压缩提交的脚本
  • Kinova在开源家庭服务机器人TidyBot++研究里大展身手
  • 使用 Spring Boot 实现文件上传:从配置文件中动态读取上传路径
  • 《鸿蒙HarmonyOS应用开发从入门到精通(第2版)》学习笔记——HarmonyOS技术理念
  • 将多个 k8s yaml 配置文件合并为一个文件