孤独的猛士

昨天看到一个很有意思的评论。

在东方大国使用chatGPT,要对抗两个超级大国的联合制裁

早上出恭时,我就在想啊,难道这不是国师们的一步大棋吗?

因为我们一直是有一个逻辑:敌人的敌人就是朋友,凡事敌人打压的,就是我们要鼓励的。

那么究竟是什么样的大棋观,让我们采取了和灯塔国一样的策略呢?我们知道灯塔人在科技方面,和老百姓民生有关的最突出表现,就是人工智能了。马斯克的火箭也很先进,毕竟离老百姓还有点远,对地球上全社会生产效率的提升也非常有限。

人工智能恰恰相反,真正能提升各行各业的生产效率,这也是灯塔作为一个超级大国的核心竞争力,就整个国家财富的指标来看,股市最有代表性,看看英伟达和微软的迅猛涨势。如果连这点优势都被东方大国夺去,我认为这个严重性要远远大于地缘政治的竞争,这属于釜底抽薪了,看看大鹅今天惨况,很容易得出这个结论–霸权没有经济支撑,最终就是一败涂地。

东方大国难道没有看到这一点吗?难道是要对方的最后一块国之命脉上发起进攻吗?当然不会,这是最大的韬光养晦。就像一个市场上竞争的两个寡头,双方打算在其他更重要领域进行合作,合作方式为一方通过示弱在人工智能行业进行了妥协,那么什么是更重要的领域呢?

12月apec会议,我们拭目以待,神秘领域自然浮现。

k8s亲和度调度

阿里云的这篇文章,介绍了如何利用亲和度(or反亲和度)特性,来实现pod的调度。
这里有一个例子,用来把pod调度到特定名字的node上。

比如要将Pod调度到nodeName是k8s-worker-2的节点上
apiVersion: v1
kind: Pod
metadata:
  name: webapp
  namespace: demo
  labels:
    app: webapp
spec:
  nodeName: 'k8s-worker-2'
  containers:
    - name: webapp
      image: nginx
      ports:
        - containerPort: 80

下面是chatgpt对这段脚本的详细解释

The YAML configuration you've provided is for a Kubernetes Pod named "webapp" in the "demo" namespace. Here's a breakdown of the configuration:

- `apiVersion: v1` and `kind: Pod`: These fields specify the Kubernetes API version and the resource type, which, in this case, is a Pod.

- `metadata`: This section contains metadata information for the Pod, such as its name, namespace, and labels.

  - `name: webapp`: The name of the Pod is set to "webapp."

  - `namespace: demo`: The Pod is created within the "demo" namespace.

  - `labels`: Labels are key-value pairs that help you organize and categorize Pods. In this case, the label "app" is set to "webapp."

- `spec`: This section defines the specifications of the Pod, including its containers, resources, and other settings.

  - `nodeName: 'k8s-worker-2'`: This field specifies the node (Kubernetes worker node) where the Pod should be scheduled. It pins the Pod to a specific node named "k8s-worker-2." This is known as node affinity and ensures that the Pod runs on a specific node, which can be useful for various scenarios such as hardware requirements or node-specific configurations.

  - `containers`: This is a list of containers running within the Pod. In this case, there is one container defined.

    - `name: webapp`: The container is named "webapp."

    - `image: nginx`: This field specifies the Docker image to use for this container. In this case, it uses the official Nginx image.

    - `ports`: This field defines the ports that are exposed by the container.

      - `containerPort: 80`: The container exposes port 80, which is the default port for HTTP traffic, allowing the Nginx web server within the container to listen for incoming HTTP requests.

This configuration will create a Pod running an Nginx web server on a specific node named "k8s-worker-2" in the "demo" namespace. The web server within the Pod will be accessible on port 80, and it has the label "app=webapp" for categorization and selection purposes.

读许倬云《现代文明的成坏》有感

在本书的最后一章,许倬云收录了自己写的一首短歌—《读北岛-青灯—有感》,其中末段他写道:

无穷折射中,
你我他,
今夕与未来,
不需分辨,
都融入N纬度的无限。
芥籽中见须弥,
刹那便是永恒——
人间在我,我在人间

他认为基督教式微后,作为人与神之间纽带的理性,徒留了“实用”这一点点的作用。儒教则自古“以人为本”,但在西方文明的冲击下,已然体无完肤。

随着科技在经济生活中的重要性与日俱增,重拾文明建设的要点,就要依托现代科技了。

科技把人与人之间的关系,重塑为一张大网,个人与这张大网形成合力,探索宇宙以发生联系。通过这一过程,让人与神再次链接起来,形成超越的价值,天人合一。

科技+儒教,从此相得益彰。

kubelet and kubectl

Kubelet and kubectl are two essential components of the Kubernetes ecosystem, each serving distinct but interconnected roles.

Kubelet:

  • Definition:

    • Kubelet is an agent that runs on each node in a Kubernetes cluster. Its primary responsibility is to ensure that the containers running on the node are in the desired state, as defined by the Kubernetes control plane.
  • Key Functions:

    • Pod Lifecycle Management: Kubelet is responsible for starting, stopping, and maintaining the lifecycle of pods on its node. It communicates with the container runtime (e.g., Docker, containerd) to create and manage containers within pods.
    • Health Checks: Kubelet regularly performs health checks on the containers it manages. If a container or pod is not healthy, Kubelet can take corrective actions, such as restarting the container.
    • Resource Management: Kubelet ensures that containers have access to the necessary resources (CPU, memory) as specified in pod resource requests and limits.
    • Image Management: Kubelet pulls container images as needed and ensures they are available for pod instantiation.
    • Node Status: Kubelet reports the node’s status and resource usage to the Kubernetes control plane.

kubectl:

  • Definition:

    • kubectl (Kube Control) is the command-line tool used to interact with a Kubernetes cluster. It serves as the primary interface for administrators, developers, and operators to manage and control the cluster.
  • Key Functions:

    • Cluster Management: kubectl allows you to create, update, and delete Kubernetes resources like pods, services, deployments, and config maps.
    • Resource Inspection: You can use kubectl to inspect the status and details of resources in the cluster, e.g., kubectl get pods, kubectl describe service.
    • Scaling: kubectl enables you to scale deployments or replica sets up or down, e.g., kubectl scale deployment my-app –replicas=3.
    • Resource Creation: You can create resources from YAML or JSON files using kubectl apply -f <file.yaml>.
    • Pod Execution: You can execute commands inside pods using kubectl exec, access logs with kubectl logs, and copy files in and out of pods with kubectl cp.
    • Interactivity: kubectl offers an interactive mode, where you can run a shell in a container using kubectl exec -it.

In summary, Kubelet is an agent running on each node that takes care of pod and container management on that node, while kubectl is the command-line tool used to manage and control the entire Kubernetes cluster from a centralized location. They work together to ensure that containerized workloads are orchestrated and maintained according to the desired configuration.

石康10月24日公众号文章

石康10月24日的公众号文章《印度智慧》一文,结尾他写到:

在历史的长河中,大家(指印度和其他国家)各走各路,各观各景,各抒各情,自享其福,自取其辱,冷暖自知,至死方休。
不过是种瓜得瓜,不足为奇。

问题是你要如何应对。
对世界,你微尘瞬间。
对个人,你一生一世。

flask的开发模式和生产模式(WSGI)

Flask容器化部署这篇文章介绍了一种利用WSGI技术,实现生产部署的方法。
WSGI介绍

我想了解flask run,下面是chatgpt的答复:

Flask is a micro web framework for Python that allows you to build web applications easily. When you use flask run to set up a web service, you are starting a development web server that comes bundled with Flask. This server is typically used for development and debugging purposes. It is not suitable for production use because it is single-threaded, not very robust, and not designed to handle a high volume of requests.

On the other hand, when you use a WSGI (Web Server Gateway Interface) server to deploy your Flask application, you are using a production-ready server to serve your application. WSGI is a standardized interface that allows web applications written in Python, like Flask, to be deployed on various web servers. When you deploy your Flask application with a WSGI server, such as Gunicorn, uWSGI, or mod_wsgi, you get a more robust and scalable web server setup that can handle concurrent requests and is better suited for production use.

Here are some key differences and considerations:

  1. Development vs. Production: flask run is intended for development and debugging, while WSGI servers are used in production environments.

  2. Scalability: WSGI servers can handle multiple concurrent requests and are suitable for scaling your application as traffic increases. Flask’s development server is not optimized for high concurrency.

  3. Reliability: WSGI servers are more reliable and have features like process management, worker processes, and failover mechanisms, making them better suited for handling production workloads.

  4. Deployment: When deploying your Flask application in a production environment, it’s recommended to use a WSGI server in conjunction with a reverse proxy server (like Nginx or Apache) for better performance, security, and load balancing.

In summary, while flask run is convenient for quickly testing your Flask application during development, it’s not suitable for production use. When deploying your Flask application for production, you should use a WSGI server for better performance, concurrency, and reliability.

在宿主机和容器里,分别查看ip地址

在mac上查看ip地址,比较方便的命令是

ifconfig en0 | grep inet

这条命令的解释如下

  1. Executes the "ifconfig" command to retrieve network configuration information for the "en0" network interface.
  2. Pipes (|) the output of the "ifconfig" command to the "grep inet" command.
  3. The "grep" command searches through the output and extracts any lines that contain the word "inet."

输出如下图

另外,也可以使用下面的命令查看ip地址,可以发现在宿主机和容器里,显示的ip地址是相同的。

# curl ifconfig.me
1.193.44.59#

宿主机

容器

解释如下

  • The command "curl ifconfig.me" is used to make an HTTP request to the ifconfig.me website, which is a service that provides your public IP address.

  • In the output you provided, "1.193.44.59" is the public IP address that was returned by the ifconfig.me service in response to your request. This is the public IP address that your device is using to communicate with the internet. It’s the address that other devices on the internet will see when they interact with your device.

  • Please note that public IP addresses can change, especially if you are using a dynamic IP assignment from your Internet Service Provider (ISP), so the IP address you see here may not be constant and could change over time.

在容器的bash环境里,输入hostname -i,显示当前容器对外暴露的ip地址

# hostname -i
XXX:XXXX:XXXa::d 192.168.194.13

这条命令解释如下

  • The command "hostname -i" is used to display the IP addresses associated with the current host or system. In the output you provided, you have two IP addresses listed:

    1. d07:b51a:cc66:a::d: This is an IPv6 address. IPv6 is the next-generation Internet Protocol designed to replace IPv4 due to the exhaustion of available IPv4 addresses.
    2. 192.168.194.13: This is an IPv4 address. IPv4 is the older and more widely used version of the Internet Protocol.
  • The output shows that your system has both an IPv6 and an IPv4 address associated with it. These addresses can be used for communication with other devices on a network, with IPv6 being used to support the transition to a more extensive address space as IPv4 addresses become scarcer.

查看docker 容器状态

有时候需要查看宿主机上的docker服务状态,以及哪些容器在运行或情况如何

查看docker服务状态

systemctl is-active docker

systemctl status docker

systemctl status [service name]命令会持续、实时显示相关服务的状态信息,如果要退出systemctl status状态回到提示符,可以:

Press Q: You can simply press the "Q" key on your keyboard to quit the "systemctl status" display. This will return you to the command line.

Press Ctrl + C: You can also press "Ctrl" and "C" simultaneously to send an interrupt signal to the "systemctl status" command, which will exit it and return you to the command line.

查看运行的容器状态

docker ps

查看所有容器状态

docker ps -a

重新启动k8s模拟器-minikube

节后上班第一天,发现阿里云上的minikube无法启动:

发现是没有切换到普通账号

su xxx到普通用户,重新启动minikube即可

如果要切换到root用户,输入多条命令,可以使用

sudo -i

The sudo -i command in Linux is used to open a new shell session with superuser privileges, also known as the root user. Here’s what it does:

sudo: This command is used to execute another command with superuser (or root) privileges, assuming the user running the sudo command has the necessary permissions. It’s often used to perform administrative tasks without needing to log in as the root user.

-i: This option, when used with sudo, opens a new shell session as the root user. It stands for "interactive" and is typically used when you need to perform multiple commands as the root user in an interactive shell. An interactive shell allows you to work as if you were logged in directly as the root user, with access to the root user’s environment and settings.

假期第二天在B站观看马斯克的最新对谈

B站的瓦砾村夫这个频道,搜集了很多与埃隆*马斯克有关的演讲、访谈,比在油管上观看还要方便。

比如最近在all in 论坛上,他也发表了对中美关系的看法,他认为中美关系的核心就是台湾问题,他也认为冲突可能会升级,在台海问题上摊牌,这也是越来多高科技产品被禁运的原因。

他还认为digital superintelligence是最重要的话题,比核武器还要重要。