<p>Getting an error in c# console application.</p>
<blockquote>
<p>Use of unassigned local variable 'KubeClient'</p>
</blockquote>
<p>I tried to use Kubernetes client in my application. But its working with the above error. I know the error is due to uninitialised variable  KubeClient. But i used this way in my webapi project. I don't understand the difference. How do i  initialise with kubernetes client.It show</p>
<blockquote>
<p>is inaccessible due to its protection level</p>
</blockquote>
<p>. plz Help me ?</p>
<p>my code is</p>
<pre><code>using k8s;
using k8s.Models;


public bool ReadTLSSecretIteratable(string secretname, string namespacename)
        {
            V1Secret sec = null;
            Kubernetes KubeClient;
            try
            {
                 sec = KubeClient.ReadNamespacedSecret(secretname, namespacename);
            }
            catch (Microsoft.Rest.HttpOperationException httpOperationException)
            {
                var content = httpOperationException.Response.Content;
                Console.WriteLine(content);
                throw httpOperationException;

            }
retrun true;
}
</code></pre>

avancho marchos
<p>As you mentioned in the question uninitialised variableis due to error.  follow the code</p>
<pre><code>Kubernetes KubeClient ;
var config = KubernetesClientConfiguration.InClusterConfig();
//for local testing BuildDefaultConfig &amp;&amp; for cluster testing InClusterConfig
KubeClient = new Kubernetes(config);
</code></pre>
