Nginx简单介绍

1. Nginx介绍

准确地说,Nginx是一个HTTP服务器和反向代理服务器,可代理通用的TCP/UDP、HTTP以及Mail等服务,最初由俄罗斯人Igor Sysoev编写,也是一款开源软件。Nginx凭借着自身强大的产品功能,已被业界广泛采用。淘宝的Tengine都是基于Nginx的。

……

阅读全文

Kubectl常用命令汇总

  1. 从容器中拷贝文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
kubectl cp -n namespace pod_name:app/test.txt ./test.txt --kubeconfig=./.kube/mykubeconfig

# 上面是linux,如果是windows的话,如下

kubectl cp -n namespace pod_name:app/test.txt .\test.txt --kubeconfig=.\.kube\mykubeconfig


# 从本地拷贝到容器里
kubectl cp -n kubesphere-controls-system .\curl kubectl-6f7f88ff9b-27lcq:tmp/curl --kubeconfig=.\.kube\local

docker cp container_name:file_path file_save_path
  1. 查看pod详情
1
kubectl describe pods -n namespace
  1. 删除节点
1
2
3
4
5
6
7
#先停止服务

systemctl stop docker

systemctl stop kubelet

kubectl delete node node_name
  1. 删除pod
1
2
3
4
kubectl delete pod pod_name -n namespace

强制删除
kubectl delete pod pod_name -n namespace --grace-period=0 --force
  1. 回滚
kubectl rollout history deployment/grafana -n kubesphere-monitoring-system

kubectl rollout history deployment/grafana --revision=83 -n kubesphere-monitoring-system

kubectl rollout undo deployment/grafana --to-revision=1 -n kubesphere-monitoring-system
  1. 进入容器
1
2
3
4
5
6
kubectl exec -it pod_name -n mynamespace --kubeconfig=/path/file -- /bin/bash

旧版命令会有相应提示,其实就是命令前面加了个'--'
[root@master ~]# kubectl exec -it nginx-deployment-f7ccf9478-ddxr6 -n default "/bin/bash"
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. 
Use kubectl exec [POD] -- [COMMAND] instead.
  1. 多集群
1
2
使用--kubeconfig
kubectl get svc -n default --kubeconfig=/path/.kube/config_file
  1. 节点label
1
2
3
4
5
6
7
8
查看
kubectl get nodes --show-labels

设置label
kubectl label nodes slave01 kubernetes.io/role=worker

覆盖
kubectl label --overwrite nodes slave01 kubernetes.io/role=worker1
  1. 查看api
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
kubectl api-resources
NAME                     SHORTNAMES   APIVERSION   NAMESPACED   KIND
bindings                              v1           true         Binding
componentstatuses        cs           v1           false        ComponentStatus
configmaps               cm           v1           true         ConfigMap
endpoints                ep           v1           true         Endpoints
events                   ev           v1           true         Event
limitranges              limits       v1           true         LimitRange


kubectl api-resources -v 6
...
I0108 ... GET https://192.168.58.2:8443/api?timeout=32s 200 OK in 10 milliseconds
I0108 ... GET https://192.168.58.2:8443/apis?timeout=32s 200 OK in 1 milliseconds
I0108 ... GET https://192.168.58.2:8443/apis/apiregistration.k8s.io/v1?timeout=32s 200 OK in 7 milliseconds
I0108 ... GET https://192.168.58.2:8443/api/v1?timeout=32s 200 OK in 13 milliseconds
...
  1. secret
# 创建tls证书
kubectl create secret tls my-tls-secret --cert=path/to/cert/file --key=path/to/key/file -n foreground --kubeconfig=.\.kube\kubeconfig

# 加密证书Opaque
kubectl create secret generic mycerts --from-file=private-rsa.pfx=.\private-rsa.pfx -n foreground  \
--kubeconfig=.\.kube\kubeconfig

然后yaml引用
```yaml
spec:
  volumes:
    - name: mycerts
      secret:
        secretName: mycerts
        defaultMode: 420
  ...
  containers:
    volumeMounts:
      - name: mycerts
        readOnly: true
        mountPath: /data/cer/

创建镜像仓库连接认证

kubectl create secret docker-registry secret-tiger-docker
docker-email=tiger@acme.example
–docker-username=tiger
–docker-password=pass1234
–docker-server=my-registry.example:5000

……

阅读全文

Haproxy简单记录

1 HAProxy介绍

HAProxy同样是一个知名的开源负载均衡器,号称提供高可用性,负载均衡和TCP、HTTP代理,使用也非常广泛。

……

阅读全文

LVS

1.1 初步介绍

负载均衡(Load balancing)是运维工程师必须要掌握的一项技术,因为其应用广泛且往往位于业务的核心位置。广义上的负载均衡是指将一组任务分配到一组资源(计算单元)上的过程。在运维领域里,则基本上是和WEB类型的业务打交道,即主要处理TCP、HTTP、HTTPS等协议。

……

阅读全文

Logstash处理Nginx日志

nginx log_format

1
2
3
4
5
6
log_format  ops '$remote_addr - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" '
                '"$http_user_agent" $http_x_forwarded_for $request_time '
                '$upstream_addr $upstream_response_time '
                '"$content_type" '
                '$host';

日志用例

……

阅读全文

LVM在线扩容分区空间

LVM一般用于linux/unix系统在线扩容磁盘空间,典型的场景比如说根分区(已是LVM)磁盘快满了,文件又不能删,这时候LVM就上场了。

……

阅读全文

Rabbitmq_权限问题

发布消息时报如下错误:

pika.exceptions.ChannelClosedByBroker: (403, “ACCESS_REFUSED - access to queue ‘hello’ in vhost ‘/’ refused for user ‘admin’

……

阅读全文

RabbitMQ介绍

1 RabbitMQ简单介绍

RabbitMQ是一个开源的消息中介软件(有时也被称为面向消息的中间件),最初实现了高级消息队列协议(AMQP),后来通过插件架构扩展了对流文本定向消息协议(STOMP)等协议的支持。

……

阅读全文

Ansible知识点

1. 指定单个ip运行(使用root用户)

ansible all -i 10.10.120.255, -m ping -u root  
 #检测连接是否正常
 10.10.120.255 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}

还有setup模块打印出的信息,在使用变量/判断的时候可以拿到很多有用的信息,比如指定操作系统平台或版本信息

……

阅读全文