public async Task <SystemInfo> GetSystemInfo() { V1NodeList k8SNodes = await this.client.ListNodeAsync(); string osType = string.Empty; string arch = string.Empty; string version = string.Empty; if (k8SNodes.Items != null) { V1Node firstNode = k8SNodes.Items.FirstOrDefault(); if (firstNode?.Status?.NodeInfo != null) { osType = firstNode.Status.NodeInfo.OperatingSystem; arch = firstNode.Status.NodeInfo.Architecture; version = firstNode.Status.NodeInfo.OsImage; } else { Events.NullNodeInfoResponse(firstNode?.Metadata?.Name ?? "UNKNOWN"); } } return(new SystemInfo(osType, arch, version)); }
/// <summary> /// Returns the <see cref="V1OwnerReference"/> for the host node. /// </summary> /// <param name="k8s">The Kubernetes client to be used to query for the node information.</param> /// <returns> /// The <see cref="V1OwnerReference"/> for the node or <c>null</c> when this couldn't /// be determined. /// </returns> public static async Task <V1OwnerReference> GetOwnerReferenceAsync(IKubernetes k8s) { Covenant.Requires <ArgumentNullException>(k8s != null, nameof(k8s)); if (NeonHelper.IsLinux) { using (await mutex.AcquireAsync()) { // Return any cached information. if (cachedOwnerReference != null) { return(cachedOwnerReference); } // Query Kubernetes for the node information based on the the node's hostname. cachedNode = await k8s.ReadNodeAsync(Name); cachedOwnerReference = new V1OwnerReference(apiVersion: cachedNode.ApiVersion, name: cachedNode.Name(), kind: cachedNode.Kind, uid: cachedNode.Uid()); return(cachedOwnerReference); } } else { // Emulate without an owner reference. return(null); } }
private async Task <string> DescribeObject(Kubernetes client, V1Node o, StringBuilder buffer) { var fetched = await client.ReadNodeAsync(o.Metadata.Name).ConfigureAwait(false); buffer.AppendLine($"API Veresion: {fetched.ApiVersion}"); buffer.AppendLine($"Kind: {fetched.Kind}"); buffer.AppendLine(DescribeMetadata(fetched.Metadata)); return($"Node - {fetched.Metadata.Name}"); }
public static IEnumerable <object[]> SystemResponseData() { var nodeFilled = new V1Node(status: new V1NodeStatus(nodeInfo: new V1NodeSystemInfo("architecture", "bootID", "containerRuntimeVersion", "kernelVersion", "kubeProxyVersion", "kubeletVersion", "machineID", "operatingSystem", "osImage", "systemUUID"))); var emptyNode = new V1Node(); yield return(new object[] { new V1NodeList(), new SystemInfo("Kubernetes", "Kubernetes", "Kubernetes") }); yield return(new object[] { new V1NodeList(new List <V1Node> { emptyNode }), new SystemInfo("Kubernetes", "Kubernetes", "Kubernetes") }); yield return(new object[] { new V1NodeList(new List <V1Node> { nodeFilled }), new SystemInfo("Kubernetes", "Kubernetes", "Kubernetes") }); }
private async Task Delete(V1Node item) { await State.Client.DeleteNodeAsync(item.Metadata.Name); }
private async Task Update() { Item = await State.Client.ReadNodeAsync(Name); StateHasChanged(); }