Setting up Clusters and work nodes - How do I set KUBECONFIG variable in Windows 10? - ibm-cloud

I using following link to create :
https://console.bluemix.net/docs/containers/cs_tutorials.html#cs_cluster_tutorial
In Lesson3, Step 3 "Verify that the KUBECONFIG environment variable is set properly.", I am unable to set the variable KUBECONFIG.
I am able to execute the following command:
ibmcloud ks cluster-config clusternameabc
I am getting following message
The configuration for clusternameabc was downloaded successfully. Export environment variables to start using Kubernetes, with the following message:
SET KUBECONFIG=C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml
When I run the above SET command in powershell, I just get the prompt back with environment variable not set.
When I do
$Env:KUBECONFIG=C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml
Notepad gets opened and this file is shown. I want to just set the environment variable and unable to. Can someone please tell me what I am doing wrong? I tried searching and could not find answers and IBM documentation has only Mac examples.

In Powershell
1) $env:KUBECONFIG = "C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml"
2) ls env:KUBECONFIG
Slightly easier to remember.

Based on my tests, you have to wrap the value of the environment environment in double quotes, like so:
$Env:KUBECONFIG="C:\Users\AAA.bluemix\plugins\container-service\clusters\customernameabc\kube-config-hou02-clusternameabc.yml"
Then, you can check the environment variables in PowerShell via this command:
Get-ChildItem Env:

Try this:
$Env:KUBECONFIG = ibmcloud cs cluster-config --export clusternameabc | Select -First 1 | % {$_.replace("SET KUBECONFIG=","")}

Related

add new environment variable [system] using power shell

I am trying to add new Environment variable in my windows 10 system , i am using below powershell command to add System variable
$env:ITH_PYTHON_PATH = 'C:\Python27\Python.exe'
i can see command is successful in adding the new values, and i can get back value when i use command $env:ITH_PYTHON_PATH.
I cannot see updated path when i manually go to the system property Environment variable
After reboot $env:ITH_PYTHON_PATH is also not seen.
Is there any better way to add environment variable permanently?
Would something like this work?
[Environment]::SetEnvironmentVariable("ITH_PYTHON_PATH", "C:\Python27\Python.exe", "Machine")

IIS Advanced Logging - Error with Configuration Editor script

I'm writing a PowerShell script to make some modifications to the Advanced Logging that's already in place on a few servers. The main issue I'm having is with the command below that was generated using Configuration Editor:
.\appcmd.exe set config "wh01-02.testlab.com" -section:system.webServer/advancedLogging/server /+"logDefinitions.[baseFileName='Log404'].filter.condition.[operator='0'].[field='Status',operator='Equals',value='404']" /commit:apphost
When I run this script, I get the following error:
ERROR ( message:Cannot find requested collection element. )
Kinda stumped on this one. Ideas anyone?
Ok, figured it out. Looks like I needed to create the 'And' operator first, then run the command:
.\appcmd.exe set config "wh01-02.testlab.com" -section:system.webServer/advancedLogging/server /+"logDefinitions.[baseFileName='Log404'].filter.condition.[operator='And']" /commit:apphost
.\appcmd.exe set config "wh01-02.testlab.com" -section:system.webServer/advancedLogging/server /+"logDefinitions.[baseFileName='Log404'].filter.condition.[operator='And'].[field='Status',operator='Equals',value='404',caseSensitive='False',regularExpression='False']" /commit:apphost

How do I set an environment variable on Windows 10, which was generated from GitHub?

I want to make an updater for my Electron application, and I stuck on the GitHub access token.
I have generated a token from my GitHub account, and after that, I tried to set that token in my Windows environmental variables.
When I go to my application and I run this file publish.sh
publish.sh
#!/bin/sh
if [ -z "$GH_TOKEN" ]; then
echo "You must set the GH_TOKEN environment variable."
echo "See README.md for more details."
exit 1
fi
# This will build, package and upload the app to GitHub.
node_modules/.bin/build --win --mac -p always
I run this file ./publish.sh and I get this message:
You must set the GH_TOKEN environment variable.
I want to achieve step 4 and 5 in this example:
https://github.com/iffy/electron-updater-example
I tried to run this command from the Git Bash export GH_TOKEN="435468246872235283762846848267", but I get a return code of 0.
How do I set an environment variable on Windows 10, which was generated from GitHub?
Make sure to restart a new CMD session (in which you can type bash) in order to make sure your session does inherit the new Windows environment variable you have just set.
Once you have done that, you can check in the (new) Git Bash session which are the environment variables already set, with:
env
env | grep GH
Make sure your script starts with
#!/bin/bash
The OP George points out in the comments that the correct form is:
export GH_TOKEN=MY_VARIABLE_NAME
(no double quotes)

Docker Toolbox Windows - Invalid volume specification

EDIT: The problem is the COMPOSE_CONVERT_WINDOWS_PATHS environment variable isn't getting set. I tried adding it to the Dockerfile and to a .env file but its not being set. I can't set any new environment variables. Its like its building it from a cached Dockerfile.
I was running docker-composer up after deleting the container, but this didn't recreate a new container, even when adding --force-recreate, it created the container from the old Dockerfile. So I ran docker build ./ instead, and it built a new container, it reinstalled all the packages, and it said that it was setting the new environment variables, but in the finished container, when I check kinematic, I see the new environment variables aren't set. But all of the old environment variables that were set when I built the container for the first time, they're all set. I don't know why this is happening, why I can't create a new container from the updated Dockerfile.
I've found a number of threads about this error, it happens when trying to mount a volume in Windows docker-tools. When I run docker-compose up, I get this error:
ERROR: for web Cannot create container for service web: Invalid bind mount spec "C:\\path\\to\\project:/app:rw": Invalid volume specification: 'C:\path\to\project:/app:rw'
[31mERROR[0m: Encountered errors while bringing up the project.
In the docker-compose file I have this:
volumes:
- ./:/app
I tried setting this environment variable:
COMPOSE_CONVERT_WINDOWS_PATHS=1
to 1, as that worked for some people in another thread but its not working in this case. I tried adding an absolute path in linux like format:
volumes:
- /c/path/to/project:/app
and I get this error:
ERROR: for web Cannot create container for service web: create \c\path\to\project: "\\c\\path\\to\\project" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed
Notice it reversed the forward slashes. Changing:
ENV COMPOSE_CONVERT_WINDOWS_PATHS=0
to 0 like that didn't change anything.
If I give a Windows format absolute directory, I get the first error again. Both of those errors, I get them if I point to a directory that doesn't exist.
Has anyone here figured out a way to resolve this?
So, if this problem exists, you should create new Windows environment variable called COMPOSE_CONVERT_WINDOWS_PATHS and set it to 1. Or you can create .env file in the path docker-compose.yml is placed with following content:
COMPOSE_CONVERT_WINDOWS_PATHS=1
..
cat >.env
COMPOSE_CONVERT_WINDOWS_PATHS=1
It looks like your COMPOSE_CONVERT_WINDOWS_PATHS=1 environment variable is not read by docker cli (powershell). you can try to run Get-childItem Env: command from your powershell console to get the list of environment variable which has been set in your powershell console. the output is like below:
Name Value
---- -----
COMPOSE_CONVERT_WINDOWS_PATHS 1
COMSPEC C:\WINDOWS\system32\cmd.exe
DOCKER_CERT_PATH C:\Users\devsa\.docker\machine\machines\default
DOCKER_HOST tcp://192.168.99.100:2376
DOCKER_TLS_VERIFY 1
...
If you don't see the COMPOSE_CONVERT_WINDOWS_PATHS=1 variable in your powershell console, it means the variable has not been set yet. To set the environment variable via powershell console, try this command:
$env:COMPOSE_CONVERT_WINDOWS_PATHS=1
it will set the environment variable in your power shell console check this powershell documentation for full documentation. Try to run the Get-childItem Env: command again to check whether the variable has been already set or not. if the variable has been set, you can try to run docker-compose up -d again.
After setting the environment variable to COMPOSE_CONVERT_WINDOWS_PATHS=1 try below setting in docker-compose
- ./app-demo:/dockermount under volumes
It worked for me

Supervisor not detecting file

I am trying to run a command via a proxy. When I run this command in shell it works
http_proxy=http://username:password#proxy:29800 /home/www/program -env prod
But when I put this into my supervisor config it tells me it can't find this file
[program:goprogram]
command = http_proxy=http://username:password#proxy:29800 home/www/program -env prod
directory = /home/www/program
enviroment=PATH='/home/www/env/bin:/usr/bin'
user = user
autorestart = true
Now, I assume it has to do with the http_proxy or syntax, but not sure how to fix it.
Since you are trying to set up an environment variable in the command itself, you might try a different way to call said command:
command = /bin/sh -c 'http_proxy=http://username:password#proxy:29800 home/www/program -env prod'
That way:
you don't have to add that environment variable to the environment section (or the credentials would be visible to all supervisord process' and child process’ environments)
you set http_proxy only for the command to be executed.
You need to set the http_proxy variable. Either the way #VonC described it or:
[program:goprogram]
command = home/www/program -env prod
directory = /home/www/program
enviroment=
PATH='/home/www/env/bin:/usr/bin'
http_proxy=http://username:password#proxy:29800
user = user
autorestart = true
More information can be found in this SO question.