Skip to content

Commit

Permalink
博客初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
QiaoKe201512 committed Sep 3, 2024
0 parents commit 1162fa3
Show file tree
Hide file tree
Showing 100 changed files with 2,734 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy VitePress site to Pages

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
# - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm # or pnpm / yarn
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: npm ci # or pnpm install / yarn install / bun install
- name: Build with VitePress
run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules

docs/.vitepress/dist
docs/.vitepress/cache
85 changes: 85 additions & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { defineConfig } from 'vitepress'
import { chineseSearchOptimize, pagefindPlugin } from 'vitepress-plugin-pagefind'

// https://vitepress.dev/reference/site-config
export default defineConfig({
base: '/blog/',
lang: 'zh-cn',
vite: {
plugins: [pagefindPlugin({
customSearchQuery: chineseSearchOptimize
})],
},
title: "乔钶的技术随笔",
description: "SRE 云原生 公有云 DEVOPS",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'K8S', link: '/k8s/index' },
{ text: '公有云', link: '/cloud' },
{ text: 'DEVOPS', link: '/devops/index' },
{ text: '监控', link: '/monitor/index' }
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/QiaoKe201512' }
],

sidebar: {
'/k8s/': k8s_sidebar(),
'/devops/': devops_sidebar(),
'/cloud/': cloud_sidebar(),
'/monitor/': monitor_sidebar()
}
}
})


// 读取指定目录生成侧边栏
function cloud_sidebar(){

return [
{
text: '首页',
link: '/cloud/index'
}
]
}

function devops_sidebar (){

return [
{
text: '首页',
link: '/devops/index'
}
]
}

function k8s_sidebar () {

return [
{
text: '首页',
link: '/k8s/index'
},
{
text: 'Docker 网络',
link: '/k8s/docker-network'
}
]
}

function monitor_sidebar() {

return [
{
text: '首页',
link: '/monitor/index'
},
{
text: 'zabbix监控方式',
link: '/monitor/zabbix-monitor-methods'
}
]
}
1 change: 1 addition & 0 deletions docs/cloud/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 公有云
1 change: 1 addition & 0 deletions docs/devops/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# devops
Empty file added docs/devops/python脚本101.md
Empty file.
39 changes: 39 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
layout: home

hero:
name: "乔钶的技术随笔"

actions:
- theme: brand
text: K8S
link: /k8s/index
- theme: alt
text: 公有云
link: /cloud/index
- theme: alt
text: DEVOPS
link: /devops/index
- theme: alt
text: 监控
link: /monitor/index

features:
- icon:
src: /kubernetes.svg
title: 云原生
details: k8s Rancher
- title: 公有云
details: AWS 阿里云 Terraform
icon:
src: /aws.svg
- title: DEVOPS
details: gitlab gitops Ansible
icon:
src: /gitlab.svg
- title: 监控
details: prometheus zabbix
icon:
src: /prometheus.svg
---

72 changes: 72 additions & 0 deletions docs/k8s/docker-network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
layout: doc
title: docker 网络
---
## Docker 网络<Badge type="info" text="docker" />

网络架构越来越复杂,但只要抓住关键点,就可以在混乱中保持清晰的思考。

1. 端点之间的连通性是关键
2. 其余的复杂度都是被附加性功能所引入,例如安全,管理的便捷性等。

四种网络模式对比:

| 网络模式 | 特点 | 应用场景 | 优劣 |
| --------- | ---------------------- | ---------------------------- | ------------------ |
| bridge | 默认模式,隔离网络 | 多个容器通信,与外部网络隔离 | 简单易用,隔离性好 |
| host | 共享宿主机的网络栈 | 访问宿主机的硬件或服务 | 性能高,配置简单 |
| container | 共享另一个容器的网络栈 | 代理、网关 | 灵活配置 |
| none | 不配置网络接口 | 自定义网络 | 完全自定义 |

### 外部访问容器

```bash
-p hostPort:containerPort
# 例子 将通过主机的80端口
ocker run -d -p 80:80 nginx:alpine
```

### 容器之间互联

通过创建bridge模式的网络来实现

```bash
docker network create -d bridge my-net
```

运行两个容器来测试互联性

```bash
docker run -it --rm --name busybox1 --network my-net busybox sh

# 打开一个新终端
docker run -it --rm --name busybox2 --network my-net busybox sh
```

![image-20240729115639045](/k8s/image-20240729115639045.png)

### 配置容器DNS

容器默认继承主机的`/etc/resolv.conf` 文件中的配置,主机中的配置变动会立即刷新到容器中。

### Docker 底层网络原理

docker 启动后会创建一个名为docker0的虚拟网桥,通过veth pair将容器网络连接到docker0

![image-20240729122135689](/k8s/image-20240729122135689.png)

### 端口映射的实现

端口映射是通过主机的iptables实现的

#### 容器访问外部

容器访问外部需要进行SNAT转换 执行 `iptables -t nat -nL`

![image-20240729130540713](/k8s/image-20240729130540713.png)

#### 外部访问容器

外部访问容器需要进行DNAT转换 执行 `iptables -t nat -nL`

![image-20240729130620239](/k8s/image-20240729130620239.png)
1 change: 1 addition & 0 deletions docs/k8s/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# k8s
1 change: 1 addition & 0 deletions docs/monitor/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 监控
Loading

0 comments on commit 1162fa3

Please sign in to comment.