Skip to content2. 檢查環境有無 defaultNodeSelector
如果沒有螢幕輸出,則跳過本步驟
螢幕輸出 :
解決辦法
如果 Neuvector 的 Enforcer DaemonSets 已建立,則須刪除 Pod,讓 Pod 重建
如果不做本步驟,你可能會再建立完 Neuvector 後,看到 Enforcer 的 Pod 出現 Pending 的狀況,並且看到類似以下的錯誤訊息
3. 檢查 CRI-O Socket 的位置
- 檢查的目的是 Neuvector 的 Controller 和 Enforcer 的 Pod 會需要 mount CRI-O Socket 的位置,所以路徑要對
- 如果 CRI-O Socket 的位置,不是
/var/run/crio/crio.sock,則需要修改 Neuvector 的 Yaml 檔
4. 檢查在叢集中的每一台 Node 上有無額外的 Taints
螢幕輸出 :
- 如果有出現除了以上 Taint 以外的 Taints 的話,需要更改 Neuvector 的 Yaml 檔裡面 Enforcer Pod 的部分
spec:
template:
spec:
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
- effect: NoSchedule
key: mykey
value: myvalue
如果有額外的 Taints 請在紅字的地方添加。這需要與污點節點上定義的所有污點信息相匹配。否則,Enforcer 的 Pod 將無法在污點節點上部署
一次檢查全部的腳本
開始安裝 Neuvector
1. Login as a normal user
2. Create a new project
3. Login as system:admin account
4. Create Service Accounts and Grant Access to the Privileged SCC
5. Create the custom resources (CRD) for NeuVector security rules. For OpenShift 4.6+ (Kubernetes 1.19+):
6. Add read permission to access the kubernetes API and OpenShift RBACs.
7. Run the following command to check if the neuvector/controller, neuvector/enforcer and neuvector/updater service accounts are added successfully.
OpenShift Deployment Examples for NeuVector
:::spoiler Sample Yaml File
:::
8. 修改 Sample Yaml 檔
8-1. 修改 Image Registry 的位置
8-2. 修改 CRI-O 的位置,如果 CRI-O Socket 的位置是 /var/run/crio/crio.sock,則不需修改
8-3. 新增多餘的 Taints,除了
[{"effect":"NoSchedule","key":"node-role.kubernetes.io/master"}][{"effect":"NoSchedule","key":"node-role.kubernetes.io/controlplane"}]
8-4. 修改 neuvector-service-webui 這個 Service 的 type 為 NodePort
9. 建立 Neuvector
10. 檢視 Neuvector 運作狀態
螢幕輸出 :
看 neuvector-manager-pod-*-* 的 Pod 在哪一台 Node 上
以及 neuvector-service-webui 這個 Service 開的 Port 好是多少
11.Access Neuvector WebUI
Neuvector Dashboard
Replacing Self-Signed Certificate
Prerequest
The NeuVector web console supports 2 different self-signed certificate types, specifically,
- PKCS8 (Private-Key Information Syntax Standard)
- PKCS1 (RSA Cryptography Standard).
The self-signed certificate can be replaced with either of these PKCS types.
what is difference between “PKCS1” and “PKCS8”?
PKCS is short for “Public Key Cryptography Standards”,中文翻譯為 “公鑰加密標準”
- PKCS1,用來定義 RSA 格式的公私鑰,是最基本的格式。
- 通過
openssl 生成的金鑰,默認私鑰是 PKCS1 格式,不會輸出公鑰(因為公鑰可以通過私鑰導出)
- PKCS8,是一種用於處理所有算法(而不僅僅是 RSA)的私鑰的標準。
| 私鑰格式 | 支持的加密算法 | 私鑰檔案內容的開頭 |
|---|
| PKCS#1 | RSA | —–BEGIN RSA PRIVATE KEY—– |
| PKCS#8 | RSA、DSA、ECDSA 等 | —–BEGIN PRIVATE KEY—– |
Create Certificate Authority
我們需要建立自己的 root CA certificate,讓瀏覽器信任自簽發憑證。
執行以下 openssl 指令,以建立 rootCA.key 和 rootCA.crt。
請將 SUSE.Lab 替換為您的網域名稱或 IP 位址。
等下會使用 rootCA.key 和 rootCA.crt 來簽署 SSL 憑證。
Create Self-Signed Certificates using OpenSSL
1. Create the Server Private Key
2. Create Certificate Signing Request Configuration
- 建立一個
csr.conf 檔案,把所有生成 CSR 所需的資訊都放進去。 - 把
ocp4.example.com 替換成你自己的網域名稱或 IP 地址。
3. Generate Certificate Signing Request (CSR) Using Server Private Key
4. Create a external file
- 執行以下命令建立
cert.conf 檔案,目的是透過這個檔案,來產生 SSL 憑證。 - 將
*.apps.ocp4.example.com 替換為你的網域名稱或 IP 地址。
5. Generate SSL certificate With self signed CA
執行以下指令產生 SSL 憑證,這個憑證是由我們自己的憑證機構所建立的 rootCA.crt 和 rootCA.key 簽署的。
上述指令會產生 server.crt 憑證,我們將與 server.key 一起使用這個憑證,以在 Neuvector web console 中啟用 SSL 功能。
Create the secret from the generated key and certificate files
執行以下命令,把要給 Neuvector 用的私鑰和憑證做成 secret
Edit the yaml directly for the manager and controller deployments to add the mounts
:::spoiler 完整的 Yaml File
:::
What is Route in OpenShift?
An OpenShift Container Platform route exposes a service at a host name, such as www.example.com, so that external clients can reach it by name.
Route Types

What is a Passthrough Route
spec.tls.termination: passthrough,With passthrough termination, encrypted traffic is sent straight to the destination without the router providing TLS termination. Therefore no key or certificate is required on the route.
建立 Neuvector
執行以下命令檢查 Pod 運行狀態和 route
螢幕輸出 :
在本機測試 Neuvector web console
- 將 CA 憑證複製到指定目錄
- 更新 Linux 系統的 CA (Certificate Authority) 信任我們自己建的 CA 憑證
- 驗證我們自己建的 CA 憑證是否由可信任的根憑證機構 (CA) 簽發
- 訪問 Neuvector web console
oc get route neuvector-route-webui 可以得到 Domain name
螢幕輸出 :
透過 Firefox 瀏覽器連線至 Neuvector web console
參考文件
Neuvector
Self-Signed Certificate
OpenShift Route