antony@notes:~/ops-automation$ cat "SREPBP.md"
SREPBP
SREPBP
Install Chocolatey
用系統管理員啟動 CMD,執行以下命令
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"allow TLS v1.2 (Required for requests to Chocolatey.org)
Getting latest version of the Chocolatey package for download.
Not using proxy.
Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/1.1.0.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/1.1.0 to C:\Users\bigred\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\bigred\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\bigred\AppData\Local\Temp\chocolatey\chocoInstall
Installing Chocolatey on the local machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
Creating Chocolatey folders if they do not already exist.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
警告: Not setting tab completion: Profile file does not exist at
'C:\Users\bigred\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring Chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder安裝 套件
choco install -y nano wget treeInstall kubectl on windows
安裝 kubectl 命令
curl -LO "https://dl.k8s.io/release/v1.25.0/bin/windows/amd64/kubectl.exe"Validate the binary (optional)
curl -LO "https://dl.k8s.io/v1.25.0/bin/windows/amd64/kubectl.exe.sha256"檢查 kubectl 版本
kubectl version --client切換到家目錄
cd %USERPROFILE%建立 .kube 目錄
mkdir .kube切換到 .kube 目錄
cd .kube將要遠端操作的 K8S Cluster 路口憑證檔拷貝至當前目錄
scp bigred@120.96.143.103:/home/bigred/.kube/config .修改 API Server IP
nano config- 將
clusters.cluster.server的設定值,設為 API-Server 的 IP 位址
檢查連線到的 K8S Cluster 資訊
kubectl cluster-infooutput :
Kubernetes control plane is running at https://120.96.143.103:6443
CoreDNS is running at https://120.96.143.103:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy測試 kubectl 命令
kubectl run nginx --image=quay.io/cloudwalker/nginx --dry-run -o yaml > pod-nginx.yaml產生 pod
kubectl apply -f pod-nginx.yaml看 pod 狀態
kubectl get podoutput :
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 43mReferences
- Install and Set Up kubectl on Windows - Kubernetes DOC
- MySQL Community Downloads
- SETUP / INSTALL Chocolately - Chocolatey DOC
- Uninstall Chocolately - Chocolatey DOC
install.bat 程式內容
@echo off
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" > nul && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" > nul && powershell -Command "choco upgrade chocolatey" > nul
if %ERRORLEVEL% == 0 echo "Chocolatey ok"
powershell -Command "choco install -y nano" > nul
if %ERRORLEVEL% == 0 echo "nano ok"
powershell -Command "choco install -y wget" > nul
if %ERRORLEVEL% == 0 echo "wget ok"
powershell -Command "choco install -y tree" > nul
if %ERRORLEVEL% == 0 echo "tree ok"
powershell -Command "choco install -y sed" > nul