我想列出kubernetes中特定命名空间中存在的所有对象。
Set objNTInfo = CreateObject("WinNTSystemInfo")
Set shell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Network = CreateObject("Wscript.Network")
Set objShell = CreateObject("Shell.Application")
Set colDrives = objFSO.Drives
Const OverwriteExisting = True
Const FOF_CREATEPROGRESSDLG = &H10&
'Get Date & time:
dateStamp = Date()
timeStamp = Time()
'Get Computer Info:
strComputer = "."
ComputerName = lcase(objNTInfo.ComputerName)
LoggedUser = lcase(objNTInfo.UserName)
windowsdir = shell.ExpandEnvironmentStrings("%windir%")
logonserver = shell.ExpandEnvironmentStrings("%logonserver%")
userprofile = shell.ExpandEnvironmentStrings("%userprofile%")
StrTimeOut = 5000
TimeOut = 0
strProcessKill = "'OUTLOOK.EXE'"
strProcessCopy = "'wscript.exe'"
' This is where WMI interrogates the operating system
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set NetcolItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
Set NetAdpItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapter")
' Here we filter Version from the dozens of properties
For Each objItem in colItems
VerBig = Left(objItem.Version,3)
OSLanguage = objItem.OSLanguage
Next
For Each objitem in NetAdpItems
'If objitem.Name <> "BlackBerry Virtual Private Network" Then
If Not InStr(objitem.Name, "VMware")<> 0 Then
If Not InStr(objitem.Name, "Microsoft")<> 0 Then
If Not InStr(objitem.Name, "Bluetooth")<> 0 Then
If Not InStr(objitem.Name, "Broadband")<> 0 Then
'WScript.Echo objitem.Name & " " & objitem.NetConnectionStatus
If objitem.NetConnectionStatus = 2 Then
For Each objitem2 in NetcolItems
If objitem2.IPAddress(0) <> "0.0.0.0" Or InStr (objitem2.IPAddress(0), "169.254.") = 0 Then
strIPAddress = Join(objitem2.IPAddress, ",")
'WScript.Echo objitem2.IPAddress(0)
End If
Next
End If
End If
End If
End if
End if
Next
'Set RunAs parameters
strAdminUser = "xxxxxxx"
strAdminPassEncrypt = "xxxxxxxx"
strAdminDomain = "xxxxx"
'Set Variable
netlogon_dir = logonserver & "\NETLOGON\xxxxx\xxxx"
LOG_DIR = "\\xxxxx\Logs$"
'RUN Only In xxxxx SubNet
If InStr(strIPAddress, "10.63.") = 0 Then
WScript.Echo "Remote backup is not supported. Backup Aborted!"
WScript.Quit(0)
End If
'Outlook Data Files (.pst) created by using Outlook 2010 are saved on your computer in the Documents\Outlook Files folder. If you are using Windows XP, these files are created in the My Documents\Outlook Files folder.
'If you upgraded to Outlook 2010 on a computer that already had data files created in previous versions of Outlook, these files are saved in a different location in a hidden folder.
'Windows 7 and Windows Vista drive:\Users\user\AppData\Local\Microsoft\Outlook
'Windows XP drive:\Documents and Settings\user\Local Settings\Application Data\Microsoft\Outlook
'Verifico che il Sistema Operativo sia XP o Windows Vista/7
If VerBig = "5.1" Then
'il SO Š XP
'Se il sistema operativo Š In italiano
If OSLanguage = "1040" Then
strUpgradeSourceDIR = userprofile & "\Impostazioni locali\Dati applicazioni\Microsoft\Outlook"
strNativeSourceDIR = userprofile & "\Documenti\File di Outlook"
Else
'se non Š italiano assumo come dafault l'inglese
strUpgradeSourceDIR = userprofile & "\Local Settings\Application Data\Microsoft\Outlook"
strNativeSourceDIR = userprofile & "\Documents\Outlook Files"
End If
'Fine controllo Lingua sistema operativo
'Controllo quale percorso utilizzare Nativo o Upgrade
If objFSO.FileExists(strNativeSourceDIR & "\Outlook.pst") Then
strSourceDIR = strNativeSourceDIR
Else
strSourceDIR = strUpgradeSourceDIR
End If
Else
'il SO Windows Vista/7
'Se il sistema operativo Š In italiano
If OSLanguage = "1040" Then
strNativeSourceDIR = userprofile & "\Documents\File di Outlook"
Else
'se non Š italiano assumo come dafault l'inglese
strNativeSourceDIR = userprofile & "\Documents\Outlook Files"
End If
'Fine controllo Lingua sistema operativo
strUpgradeSourceDIR = userprofile & "\AppData\Local\Microsoft\Outlook"
If objFSO.FileExists(strNativeSourceDIR & "\Outlook.pst") Then
strSourceDIR = strNativeSourceDIR
Else
strSourceDIR = strUpgradeSourceDIR
End If
End If
strTargetDIR = "U:\Mail_current"
For Each objDrive in colDrives
If objDrive.DriveType = 3 And objDrive.DriveLetter = "U" Then
strUNCTargetDIR = objDrive.ShareName
End If
Next
check_file = strSourceDIR & "\COPIAPOSTA"
'Log file
log_Copia_Posta_In_Rete_file = LOG_DIR & "\UTILITIes\Copia_Posta_In_Rete\" & ComputerName & ".txt"
'Log File Header
strtitle = vbNewLine & "-------------------------------------------------------------------"
strtitle = strtitle & vbNewLine & dateStamp & " " & timeStamp & " - Utente: " & LoggedUser & " sul Computer: " & ComputerName
strtitle = strtitle & vbNewLine & check_file
Set objFolder = objShell.NameSpace(strTargetDIR)
If objFSO.FileExists(check_file) Then
strtitle = strtitle & vbNewLine & "File COPIAPOSTA OK"
If objFSO.FolderExists(strTargetDIR) Then
strtitle = strtitle & vbNewLine & strTargetDIR
Const POPUP_TIMEOUT = 180
Const POPUP_TITLE = "Backup Outlook e-mail messages"
Set objShell = WScript.CreateObject("WScript.Shell")
Call WriteLOG (strtitle, log_Copia_Posta_In_Rete_file)
'get TargetFileDate
On Error Resume Next
Set File = objFSO.GetFile(strTargetDIR & "\Outlook.pst")
strTargetFileDate = File.DateLastModified
'ask for backup
acctType = objShell.Popup("Do you want backup your e-mail messages now?" & vbCrLf & vbCrLf & "Last Backup date: " & strTargetFileDate & _
vbCrLf & "Default answer: YES" & vbCrLf & "Timeout: " & POPUP_TIMEOUT & " Sec", _
POPUP_TIMEOUT,POPUP_TITLE,vbQuestion+vbYesNo)
If acctType = vbNo Then
Call WriteLOG ("L'utente ha negato il Backup!", log_Copia_Posta_In_Rete_file)
Else
Call WriteLOG ( "L'utente ha accettato di effettuare il Backup!", log_Copia_Posta_In_Rete_file)
'Closing Outlook
Set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name=" & strProcessKill
Set cproc=svc.execquery(sQuery)
iniproc=cproc.count 'it can be more than 1
Do While iniproc = 1
set otl = nothing
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name=" & strProcessKill
set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Set otl = getobject(,"outlook.application")
If not otl is Nothing Then
On Error Resume Next
otl.Quit
'WScript.Echo ("Still Running, waiting...")
End If
TimeOut=TimeOut+1
'wscript.echo ("-" & TimeOut)
If TimeOut=StrTimeOut Then
'wscript.echo ("Kill Local Process of Outlook")
Call WriteLOG ("Kill Local Process of Outlook", log_Copia_Posta_In_Rete_file)
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
End If
Loop
'Copy
Call WriteLOG ("Inizio processo di copia...", log_Copia_Posta_In_Rete_file)
Set oExec = shell.Exec(windowsdir & "\System32\cmd.exe /C xcopy /Y " & Chr(34) & strSourceDIR & "\Outlook.pst" & Chr(34) & " " & strTargetDIR & "\" )
Do While oExec.Status = 0
shell.Popup "Backup operations are in progress please wait!", 1, POPUP_TITLE, 64
Loop
'-----shell.Popup "Backup operations are in progress please wait!", 6000, POPUP_TITLE, 64
'WScript.Sleep (600)
'objFolder.CopyHere strSourceDIR & "\Outlook.pst" , &H10& + &H100& + &H80& + &H200& +&H0&
'WScript.echo windowsdir & "\System32\cmd.exe /C xcopy /Y " & Chr(34) & strSourceDIR & "\Outlook.pst" & Chr(34) & " " & strTargetDIR & "\"
'---->shell.run windowsdir & "\System32\cmd.exe /C xcopy /Y " & Chr(34) & strSourceDIR & "\Outlook.pst" & Chr(34) & " " & strTargetDIR & "\" , 0, True
'WScript.Sleep (6000)
Call WriteLOG ("Fine processo di copia...", log_Copia_Posta_In_Rete_file)
'get SourceFileDate AND strTargetFileDate
Set File = objFSO.GetFile(strTargetDIR & "\Outlook.pst")
strTargetFileDate = File.DateLastModified
File = Nothing
Set File = objFSO.GetFile(strSourceDIR & "\Outlook.pst")
strSourceFileDate = File.DateLastModified
If Not objFSO.FileExists(strTargetDIR & "\Outlook.pst") Then
'RunAsAdmin
strCommand = "cmd /c " & netlogon_dir & "\lsrunase.exe /superscript /user:" & strAdminUser & " /password:" & strAdminPassEncrypt & " /domain:" & strAdminDomain & " /command:" & Chr(34) & "wscript.exe " & netlogon_dir & "\" & "RestorePSTFile.vbe " & strUNCTargetDIR & " " & LoggedUser & " " & logonserver & Chr(34) & " /runpath:c:\"
'Wscript.Echo strCommand
Shell.Run strCommand, 0, True
WScript.Echo "Backup Interrotto! - ATTENZIONE: non Š pi— presente un backup valido sul server!"
Call WriteLOG ("Backup Interrotto! - ATTENZIONE: non Š pi— presente un backup valido sul server!" & strTargetFileDate, log_Copia_Posta_In_Rete_file)
End If
If strSourceFileDate = strTargetFileDate Then
Call WriteLOG ("Backup eseguito correttamente!", log_Copia_Posta_In_Rete_file)
' User Notification
shell.Popup "Backup completed successfully!", 10, POPUP_TITLE, 64
Set shell = Nothing
Else
Call WriteLOG ("L'ultimo backup della posta Š stato effettuato il " & strTargetFileDate, log_Copia_Posta_In_Rete_file)
End If
End If
Else
Call WriteLOG (strTargetDIR & " does not exist", log_Copia_Posta_In_Rete_file)
End If
Else
Call WriteLOG ("L'utente " & LoggedUser & " non e' abilitato a copiare outlook.pst su U:\ dal computer " & ComputerName, log_Copia_Posta_In_Rete_file)
End If
'****************************************************************
Sub WriteLOG(Value, DestFileName)
'Open up the path to save the information into a text file
On Error Resume Next
Dim Stuff, WriteStuff, dateStamp
'Write information to Text File
Set WriteStuff = objFSO.OpenTextFile(DestFileName, 8, True)
WriteStuff.WriteLine(Value)
WriteStuff.Close
Set WriteStuff = Nothing
End Sub
以上命令未列出给定名称空间中的所有可用对象。有没有办法使用kubectl列出它们?
我可以通过将它们传递给kubectl列出所有想要的对象。但是我不要。
kubectl get all -n <namespace>
答案 0 :(得分:1)
首先,以下所有规则决定资源是否属于 all 类别的一部分。
以下是向kubectl get all输出添加新资源的规则。
没有群集范围的资源
没有名称空间管理员级别的资源(限制,配额,策略,
授权规则)
没有可能不可恢复的资源(秘密和pvc)
被认为与#3“相似”的资源应归为
相同(配置映射)
要回答您的问题,该内容取自rcorre's Answer
kubectl api-resources --verbs=list --namespaced -o name \
| xargs -n 1 kubectl get --show-kind --ignore-not-found -l <label>=<value> -n <namespace>
最后,如果要在所有类别中添加自定义资源,则需要在CRD规范中提供这些字段。 custom-resource-definitions:categories
# categories is a list of grouped resources the custom resource belongs to.
categories:
- all
答案 1 :(得分:0)
答案 2 :(得分:0)
试试:
kubectl -n your_namespace get all