Skip to content

Commit

Permalink
Update posts
Browse files Browse the repository at this point in the history
  • Loading branch information
nighon committed Nov 22, 2024
1 parent 6381eb2 commit 7c6d983
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 82 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

## 安装 Ruby

```shell
```console
$ rbenv install 3.3.3
$ rbenv global 3.3.3
$ rbenv versions
```

## 安装第三方库

```shell
```console
$ gem update --system
$ gem install bundler
$ bundle update
```

## 启动

```shell
```console
$ jekyll serve
# $ bundle exec jekyll serve
```

## 生成语法高亮样式

```shell
```console
$ rougify help style
$ rougify style github > assets/css/highlight-github.css
```
14 changes: 7 additions & 7 deletions _drafts/2018-06-24-install-ruby-with-rbenv.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ color: "#fff"

先安装依赖包

```shell
```console
$ sudo apt-get update
$ sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
```

接着安装 rbenv,如果是 macos,推荐使用 Homebrew 安装。

```shell
```console
$ brew install rbenv
$ echo 'export PATH="$PATH:$HOME/.rbenv/bin"' >> ~/.zshrc
$ echo 'eval "$(rbenv init -)"' >> ~/.zshrc
Expand All @@ -31,34 +31,34 @@ $ source ~/.zshrc

Restart your shell so that PATH changes take effect. Verify that rbenv is properly set up using this rbenv-doctor script 重新打开 Shell,使 PATH 生效。用 `type rbenv` 或者下面语句来检验 rbenv 是否已经设置好了。

```shell
```console
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
```

### Install ruby-build as an rbenv plugin(安装插件 ruby-build)

```shell
```console
$ mkdir -p "$(rbenv root)"/plugins
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
```

### Install Ruby

```shell
```console
$ rbenv install --verbose 2.7.2
```

如果无法直接在线安装,可以[安装下载好的 Ruby 文件](https://stackoverflow.com/questions/35589469/install-ruby-using-rbenvs-downloaded-file/35589999#35589999)

```shell
```console
$ mkdir ~/.rbenv/cache
$ cp ~/Downloads/ruby-2.7.2.tar.bz2 ~/.rbenv/cache/
$ env RUBY_BUILD_MIRROR_URL=file:///home/$(whoami)/.rbenv/cache/ruby-2.7.2.tar.bz2
```

### Set default Ruby(设置默认的 Ruby 版本)

```shell
```console
$ rbenv global 2.7.2
$ rbenv versions
```
12 changes: 6 additions & 6 deletions _drafts/2018-07-19-install-express-nginx-docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Compose is a tool for defining and running multi-container Docker applications.

Run this command to download the latest version of Docker Compose:

```shell
```console
$ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
```

Apply executable permissions to the binary:

```shell
```console
$ sudo chmod +x /usr/local/bin/docker-compose
```

Expand Down Expand Up @@ -55,7 +55,7 @@ mongodb:
创建 VOLUMES 目录
```shell
```console
$ mkdir -p /home/vagrant/nginx/conf.d
$ mkdir -p /home/vagrant/mongodb
```
Expand All @@ -79,15 +79,15 @@ server {

运行 docker-compose

```shell
```console
$ docker-compose -f compose-nginx-nodejs-mongodb.yml up
```

最后,打开浏览器:http://192.168.33.90,你应该能看到 Counter 字样。

## 常用命令

```shell
```console
$ docker volume ls
$ docker volume prune
$ docker volume inspect delivery_storage
Expand All @@ -107,7 +107,7 @@ $ docker-compose exec fpm php artisan route:cache

您需要使用注册表名称和要将其推送到的存储库来标记您的映像。 例如,要将名为 my-image 的映像推送到 Docker Hub 注册表,您可以使用以下命令:

```shell
```console
$ docker tag my-image:latest docker.io/my-username/my-image:latest
$ docker push docker.io/my-username/my-image:latest
```
Expand Down
4 changes: 2 additions & 2 deletions _drafts/2020-03-18-terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ HashiCorp 维护着广泛的官方提供商列表,并且还可以与社区开

首先,安装 HashiCorp Tap,它是我们所有 Homebrew 软件包的存储库。

```shell
```console
$ brew tap hashicorp/tap
```

现在,使用 hashcorp/tap/terraform 安装 Terraform。

```shell
```console
$ brew install hashicorp/tap/terraform
```

Expand Down
28 changes: 14 additions & 14 deletions _drafts/2020-11-20-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ Kubernetes 常用命令

## Deployment(部署)

```shell
```console
$ kubectl get deployments # List deployments(查看列表 deployments)
$ kubectl get pods -o wide # let’s check if the number of Pods changed (查看列表 Pods)
```

## Scale(扩展)

```shell
```console
$ kubectl get rs # Show replicas
$ kubectl scale deployments/kubernetes-bootcamp --replicas=4 # Scale up
$ kubectl scale deployments/kubernetes-bootcamp --replicas=2 # Scale down
$ kubectl describe deployments/kubernetes-bootcamp # The change was registered in the Deployment events log.
```

```shell
```console
{% raw %}$ export NODE_PORT="$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}')"{% endraw %}
$ echo "NODE_PORT=$NODE_PORT"
$ curl http://"$(minikube ip):$NODE_PORT"
Expand All @@ -34,70 +34,70 @@ $ curl http://"$(minikube ip):$NODE_PORT"
回滚更新
让我们执行另一次更新,并尝试部署带有 v10 标记的映像:

```shell
```console
$ kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=gcr.io/google-samples/kubernetes-bootcamp:v10
```

使用 get deployments 查看部署的状态:

```shell
```console
$ kubectl get deployments
```

请注意,输出并未列出所需的可用 Pod 数量。 运行 get pods 子命令以列出所有 Pod:

```shell
```console
$ kubectl get pods
```

请注意,某些 Pod 的状态为 ImagePullBackOff。

要更深入地了解问题,请运行 describe pods 子命令:

```shell
```console
$ kubectl describe pods
```

在受影响 Pod 的输出的“事件”部分中,请注意存储库中不存在 v10 映像版本。

要将部署回滚到上一个工作版本,请使用 rollout undo 子命令:

```shell
```console
$ kubectl rollout undo deployments/kubernetes-bootcamp
```

rollout undo 命令将部署恢复到之前的已知状态(映像的 v2)。 更新已进行版本控制,您可以恢复到任何先前已知的部署状态。

使用 get pods 子命令再次列出 Pod:

```shell
```console
$ kubectl get pods
```

四个 Pod 正在运行。 要检查部署在这些 Pod 上的映像,请使用describe pods 子命令:

```shell
```console
$ kubectl describe pods
```

部署再次使用应用程序的稳定版本 (v2)。 回滚成功。

请记住清理本地集群

```shell
```console
$ kubectl delete deployments/kubernetes-bootcamp services/kubernetes-bootcamp
```

## 获取配置上下文,切换环境

```shell
```console
$ kubectl config --kubeconfig=$HOME/.kube/config get-contexts # 列出上下文环境
$ kubectl config --kubeconfig=$HOME/.kube/config use-context minikube # 使用上下文环境
```

比如,要切换到腾讯云 TKE

```shell
```console
$ export KUBECONFIG=$KUBECONFIG:$HOME/cls-7ta42ut4-config # 先添加新的上下文环境

$ kubectl config --kubeconfig=$HOME/cls-7ta42ut4-config get-contexts
Expand All @@ -108,7 +108,7 @@ $ kubectl config --kubeconfig=$HOME/cls-7ta42ut4-config use-context cls-7ta42ut4
Switched to context "cls-7ta42ut4-100000777545-context-default".
```

```shell
```console
$ kubectl get pods --field-selector=status.phase=Failed
$ kubectl delete pods --field-selector=status.phase=Failed # 批量删除
```
2 changes: 1 addition & 1 deletion _drafts/2021-02-24-helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Helm 是 Kubernetes 的包管理器,Kubernetes 是一个开源容器编排平

## 安装

```shell
```console
$ brew install helm
```
4 changes: 2 additions & 2 deletions _drafts/2023-07-31-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Often, cargo check is much faster than cargo build because it skips the step of

让我们回顾一下我们到目前为止对 Cargo 的了解:

```shell
```console
$ cargo new # 创建一个项目。
$ cargo build # 构建一个项目。
$ cargo run # 一步构建和运行一个项目。
Expand Down Expand Up @@ -56,4 +56,4 @@ $ cargo build
直接使用 rustc 编写和运行“Hello, world!”程序

使用 Cargo 的约定创建和运行新项目
这是构建更实质性的程序以习惯于阅读和编写 Rust 代码的好时机。因此,在第 2 章中,我们将构建一个猜谜游戏程序。如果您更愿意先了解 Rust 中常见的编程概念,请参阅第 3 章,然后再返回第 2 章。
这是构建更实质性的程序以习惯于阅读和编写 Rust 代码的好时机。因此,在第 2 章中,我们将构建一个猜谜游戏程序。如果您更愿意先了解 Rust 中常见的编程概念,请参阅第 3 章,然后再返回第 2 章。
Loading

0 comments on commit 7c6d983

Please sign in to comment.