Tailwindcss

tailwindcss 一直不生效 使用如下配置 /** @type {import('tailwindcss').Config} */ export default { content: ['./index.html', './src/**/*.{html, ts, tsx}'], theme: { extend: {}, }, plugins: [], corePlugins: { preflight: false, }, }; 搜了半天,也没找到原因,结果发现是多了个空格 {html,ts,tsx} 逗号后面不能加空格,ᕙ(⇀‸↼‶)ᕗ

March 6, 2024 · homfen

让多个Pod均匀部署到各个节点上

Kubernetes中kube-scheduler组件负责Pod的调度,对每一个新创建的 Pod 或者是未被调度的 Pod,kube-scheduler 会选择一个最优的节点去运行这个 Pod。kube-scheduler 给一个 Pod 做调度选择包含过滤和打分两个步骤。过滤阶段会将所有满足 Pod 调度需求的节点选出来,在打分阶段 kube-scheduler 会给每一个可调度节点进行优先级打分,最后kube-scheduler 会将 Pod 调度到得分最高的节点上,如果存在多个得分最高的节点,kube-scheduler 会从中随机选取一个。 打分优先级中节点调度均衡(BalancedResourceAllocation)只是其中一项,还有其他打分项会导致分布不均匀。详细的调度说明请参见Kubernetes 调度器和调度策略。 想要让多个Pod尽可能的均匀分布在各个节点上,可以考虑使用工作负载反亲和特性,让Pod之间尽量“互斥”,这样就能尽量均匀的分布在各节点上。 kind: Deployment apiVersion: apps/v1 metadata: name: nginx namespace: default spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: container-0 image: nginx:alpine resources: limits: cpu: 250m memory: 512Mi requests: cpu: 250m memory: 512Mi affinity: podAntiAffinity: # 工作负载反亲和 preferredDuringSchedulingIgnoredDuringExecution: # 尽量满足如下条件 - podAffinityTerm: labelSelector: # 选择Pod的标签,与工作负载本身反亲和 matchExpressions: - key: app operator: In values: - nginx namespaces: - default topologyKey: kubernetes....

August 24, 2023 · homfen

Aliyun K8s 会话保持

阿里云不支持 Web 端的 websocket,所以使用 socket.io,通过 http 模拟 websocket 遇到的问题是,socket 建立连接之后,就必须保持这个连接,而 k8s 默认负载均衡会把http 请求随机打到一台 pod 上 所以就需要会话保持,保证从建立连接开始,所有的请求都打到同一个 pod apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-persistence-timeout: "60" name: service namespace: default spec: ports: - protocol: TCP port: 80 targetPort: 8088 selector: app: server sessionAffinity: ClientIP sessionAffinityConfig: clientIP: timeoutSeconds: 10800 type: LoadBalancer

August 14, 2023 · homfen

Grafana Mongodb

Grafana是一个流行的开源数据可视化和监控平台,它提供了丰富的数据可视化、查询和面板编辑功能,可以帮助用户通过图表、仪表盘等形式直观地展示和分析数据。Grafana支持多种数据源,包括Graphite、Prometheus、InfluxDB、Elasticsearch、MySQL等,并且提供了许多插件和API,可以方便地扩展和定制功能。Grafana广泛应用于各种领域,包括IT运维、物联网、工业自动化等。 从docker hub获取最新镜像 docker pull grafana/grafana Grafana的MongoDB插件是收费的,所以用社区版本 从github下载release的zip包 启动容器并安装插件 docker run \ -d \ --name grafana \ -p 3000:3000 \ -e GF_INSTALL_PLUGINS="${ZIP_URL};meln5674-mongodb-community" \ -e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=meln5674-mongodb-community \ grafana/grafana-oss:latest 此插件只支持aggregation方式的查询 [ { "$group": { "_id": null, "total": {"$sum": 1} } } ]

April 17, 2023 · homfen

Ansible Playbook

Ansible Ansible是一种自动化工具,用于在多个计算机上自动化配置、部署和管理软件应用程序。它是一种基于代理的工具,可以在远程计算机上执行命令,同时也可以通过 SSH 和 WinRM 等协议进行管理。 Playbook 在 Ansible 中,playbook 是一种定义要在目标主机上执行的一系列任务和操作的文件。它可以用来自动化常见的 IT 工作流程,例如软件配置、部署、编排和管理。 每个 playbook 都是一个 YAML 文件,其中包含一组任务列表。任务是 Ansible playbook 的最基本的组成部分,表示要在目标主机上执行的操作。每个任务都包括一个或多个动作,这些动作定义了要执行的具体操作,例如运行命令、复制文件、安装软件包等。 除了任务和动作,playbook 还包括变量、条件语句、循环和角色等高级特性,可以使 playbook 更加灵活和可重用。 --- - hosts: all tasks: - name: "remove old files" shell: rm -rf /home/hf/new-version - name: "mkdir" shell: mkdir -p /home/hf/new-version - name: "copy files" copy: src: /home/semaphore/service.tar dest: /home/hf/new-version owner: hf group: hf mode: 0644 - name: "tar xzvf" shell: tar xzvf service.tar args: chdir: /home/hf/new-version - name: "kill" shell: kill -9 $(pgrep -f 'my_app....

April 6, 2023 · homfen

Docker Proxy

host.docker.internal 是一个特殊的 DNS 名称,用于在 Docker 容器中访问宿主机的网络服务。这个 DNS 名称只在 Docker for Mac 和 Docker Desktop 等桌面平台上可用,用于解决在容器内部无法直接访问宿主机上的网络服务的问题。 在 Docker for Mac 和 Docker Desktop 等平台上,Docker 会在容器的网络配置中自动添加 host.docker.internal 主机名,并将其映射到宿主机的 IP 地址。因此,在容器内部可以使用 host.docker.internal 主机名来访问宿主机上的网络服务,就好像访问本地主机一样。 使用以下命令启动容器,并将宿主机的 IP 地址和主机名映射到容器内部: docker run --add-host=proxy:<host_ip_address> <image> 在容器中设置http_proxy和https_proxy export http_proxy=http://proxy:<port> export https_proxy=http://proxy:<port> 如果要加宿主机的代理,直接使用host.docker.internal export http_proxy=http://host.docker.internal:<port> export https_proxy=http://host.docker.internal:<port>

April 6, 2023 · homfen

Nginx Reverse Proxy and Cors

后端部署的服务有跨域,可以通过Nginx反向代理解决 nginx配置 将example.com:8888代理到example.com:8088 user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; server { listen 8888; server_name example.com; location / { add_header 'Access-Control-Allow-Origin' "$http_origin"; add_header 'Access-Control-Allow-Credentials' "true"; if ($request_method = "OPTIONS") { add_header 'Access-Control-Max-Age' 86400; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE'; add_header 'Access-Control-Allow-Headers' 'reqid, nid, host, x-real-ip, x-forwarded-ip, event-type, event-id, accept, content-type'; add_header 'Content-Length' 0; add_header 'Content-Type' 'text/plain, charset=utf-8'; return 204; } root /usr/share/nginx/html; index index....

March 23, 2023 · homfen

gin SPA config

最近在做一个项目,使用golang做后端,react做前端。 后端用的是百度的golang框架GDP,对路由、数据库等做了封装,web内核目前是基于开源项目Gin实现。 由于react是SPA应用,所以需要用golang进行分流,默认路由到前端的静态目录,/api的请求则由golang处理。 ...

July 25, 2019 · homfen

Docker部署Hadoop

学习Hadoop,首先想到的是用虚拟机,但是虚拟机配置繁琐,而且多个节点占用资源也很大,那就用docker吧 在dockerhub上找了一圈,发现这个还不错: docker pull harisekhon/hadoop:2.9 只是版本最高只有2.9,但是练习应该够了 查看项目可以发现,在根目录下有一个entrypoint.sh文件,作为入口,如果不传任何参数,就会执行初始化,如果传了参数,就会把这个参数作为命令执行 所以我们创建一个容器 docker run -d IMAGE-ID /entrypoint.sh ...

April 3, 2019 · homfen

Protobuf

最近在用 Go 重构一个项目,其中就用到了 Protobuf。 Protobuf 是 Google Protocol Buffer 的简称,是一种结构化数据存储格式,用于对数据进行序列化和反序列化。由于是二进制的数据格式,所以具有更高的打包、传输、解包效率。文件以.proto 为后缀,详细语法看文档。 在 Go 中使用 Protobuf,需要安装编译工具,用于将 proto 文件编译为 go 包。 ...

August 10, 2018 · homfen