Skip to content

Instantly share code, notes, and snippets.

View Shenderchuk's full-sized avatar

Igor Shenderchuk Shenderchuk

  • SoftServe
  • Kyiv, Ukraine
View GitHub Profile
# Get Service Account name for the pod
k -n argocd get pod/argocd-redis-868b8cb57f-pp7hv -o json | jq .spec.serviceAccountName
# Set current context
kubectl config set-context --current --namespace monitoring
# Check if Service Account can use some policy
kubectl auth can-i use podsecuritypolicy/000-aurora-argocd-psp --as=system:serviceaccount:argocd:argocd-grpc-svc-nginx-ingress
# Scaling up or down replicaset

Keybase proof

I hereby claim:

  • I am shenderchuk on github.
  • I am shenderchuk (https://keybase.io/shenderchuk) on keybase.
  • I have a public key ASBxo4DjbfksJc12Qy799pJSd6KPSg_aF5pvz9kWTVUJ1wo

To claim this, I am signing this object:

@Shenderchuk
Shenderchuk / push_ssh_key.sh
Last active May 24, 2018 09:02
the script generate tmp private/public keypair and push it to server, creates ssh_config file which can be used to login
#!/bin/bash
host=$1
mkdir -p ~/.ssh
echo "y" | ssh-keygen -t rsa -N "" -f ~/.ssh/tmp_rsa_id -C "temporary key for testing"
chmod 0400 ~/.ssh/tmp_rsa_id
sshpass -pVERYSECUREPASSWORD ssh-copy-id -i ~/.ssh/tmp_rsa_id.pub SOMEUSERNAME@${host} -o "StrictHostKeyChecking=no"
echo $'Host target\n\tStrictHostKeyChecking no\n\tIdentityFile ~/.ssh/tmp_rsa_id\n\tUser SOMEUSERNAME\n\tPort 22\n\tHostName'" ${host}" > tmp_ssh_config
$vmname = "MyLinuxVM"
[Microsoft.HyperV.PowerShell.VMNetworkAdapter]$NetworkAdapter = Get-VMNetworkAdapter -VMName $vmname
$VM = Get-WmiObject -Namespace 'root\virtualization\v2' -Class 'Msvm_ComputerSystem' | Where-Object { $_.ElementName -eq $NetworkAdapter.VMName }
$VMSettings = $vm.GetRelated('Msvm_VirtualSystemSettingData') | Where-Object { $_.VirtualSystemType -eq 'Microsoft:Hyper-V:System:Realized' }
$VMNetAdapters = $VMSettings.GetRelated('Msvm_SyntheticEthernetPortSettingData')
$NetworkSettings = @()
foreach ($NetAdapter in $VMNetAdapters) {
1. get the jenkins cli
The jenkins CLI will allow us to interact with our jenkins server from the command line. We can get it with a simple curl call.
curl 'localhost:8080/jnlpJars/jenkins-cli.jar' > jenkins-cli.jar
2. create a groovy script for parsing (thanks to malenkiy_scot)
Save the following as plugins.groovy.
Describe "Valid PowerShell code" {
# Checks if PowerShell code has correct format by reading count of errors after parsing
#$ps1file = "c:\temp\test1.ps1"
It "Script is valid PowerShell code" {
$psFile = Get-Content -Path $ps1file -ErrorAction Stop
$errors = [System.Management.Automation.PSParseError[]] @()
$Tokens = [System.Management.Automation.PSParser]::Tokenize($psFile, [ref]$errors)
$errors.Count | Should Be 0
}
}
Describe "New-RemoteTest" {
# Standard prerequisites logic block for remote Pester testing.
#$ComputerName = "localhost"
#$Credentials = Get-Credential
# All conditions in script blocks {} should be true to run Pester test,
# in other case testing will be canceled
$conditions = @(
{Test-Connection -ComputerName $ComputerName -Quiet -Count 1}
Describe "New-test" {
It "Disk C: exists" {
# Standard prerequisites logic block.
# All conditions in script blocks {} should be true to run Pester test,
# in other case test will be marked as Inconclusive
$conditions = @(
{Test-Path -Path C:}
{-not (Test-Path -Path D:)}
)
#Copy dll from WiX binary files (version 3.10.3)
# Add Required Type Libraries
Add-Type -Path "C:\Temp\Microsoft.Deployment.WindowsInstaller.dll"
# Open an MSI Database
$oDatabase = New-Object Microsoft.Deployment.WindowsInstaller.Database("C:\Temp\Bliss_LP_net.msi", [Microsoft.Deployment.WindowsInstaller.DatabaseOpenMode]::Direct);
#Create a Select Query against an individual property
$sSQLQuery = "SELECT * FROM Property WHERE Property= 'ProductCode'"