Skip to content

Commit 81b5f40

Browse files
authoredAug 19, 2023
Merge pull request #17 from sharadregoti/v0.5.3
v0.5.3
2 parents 4c0cf43 + a414b8c commit 81b5f40

File tree

10 files changed

+134
-6
lines changed

10 files changed

+134
-6
lines changed
 

‎.github/workflows/version-release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
git checkout ${{ steps.current-branch.outputs.branch}}
6565
git checkout -b "temp-branch"
6666
TIMESTAMP=$(date +%s)
67-
git tag -a "v0.5.2" -m "dummy tag"
67+
git tag -a "v0.5.3" -m "dummy tag"
6868
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
6969
7070
echo "Running script..."

‎cmd/devops/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/spf13/viper"
2525
)
2626

27-
const VERSION = "0.5.2"
27+
const VERSION = "0.5.3"
2828

2929
// @title NEW Devops API
3030
// @version v0.1.0
1.98 KB
Loading
3.08 KB
Loading
2.43 KB
Loading

‎devops-frontend/src/components/sideNav/SideNav.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Menu, MenuProps } from "antd"
22
import Sider from "antd/es/layout/Sider"
3-
import { useEffect, useState } from "react";
3+
import { ReactNode, useEffect, useState } from "react";
44
import { useDispatch, useSelector } from "react-redux";
5+
import Icon, { HomeOutlined } from '@ant-design/icons';
56
import { NavBarItem, NavBarState } from "../../redux/reducers/PluginSelectorReducer";
67
import {
78
PieChartOutlined, AppstoreFilled, RightCircleFilled
@@ -16,23 +17,31 @@ export type SideNavProps = {
1617
newNavItem?: NavBarItem
1718
}
1819

20+
21+
import kubernetesImage from '../../assets/kubernetes32.png';
22+
import helmImage from '../../assets/helmicon-32.png';
23+
1924
const SideNav: React.FC<SideNavProps> = ({ selectedItem, newNavItem }) => {
2025
const navigate = useNavigate();
2126
const dispatch = useDispatch();
2227
const { items } = useSelector((state: NavBarState) => state.navBar);
2328
const [collapsed, setCollapsed] = useState(true);
2429
const [navBarItems, setNavBarItems] = useState<MenuItem[]>([])
2530

31+
2632
function getNavBarItem(
2733
auhtId: string,
2834
pluginName: string,
2935
label: React.ReactNode,
3036
key: React.Key,
3137
children?: MenuItem[],
38+
icon?: ReactNode,
3239
): MenuItem {
3340
return {
41+
// <img src={pluginName === "kubernetes" ? kubernetesImage : helmImage} />
42+
style: { "display": "flex", "align-items": "center" },
3443
key,
35-
icon: label === "Plugins" ? <AppstoreFilled /> : <RightCircleFilled />,
44+
icon: label === "Plugins" ? <AppstoreFilled /> : <img src={pluginName === "kubernetes" ? kubernetesImage : helmImage} />,
3645
children,
3746
label: label === "Plugins" ? label : `${pluginName} :: ${auhtId} :: ${label}`,
3847
onClick: () => {

‎plugins/kubernetes/implementation.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func (d *Kubernetes) Connect(authInfo *proto.AuthInfo) error {
6161
// List all supported resources
6262
resources, err := clientset.Discovery().ServerPreferredResources()
6363
if err != nil {
64-
return fmt.Errorf("failed to discover kubernetes resource types: %w", err)
64+
shared.LogDebug("failed to discover kubernetes resource types: %w", err)
65+
// return fmt.Errorf("failed to discover kubernetes resource types: %w", err)
6566
}
6667

6768
// Resource Type List
@@ -222,6 +223,16 @@ func (d *Kubernetes) WatchResources(args *proto.GetResourcesArgs) (chan shared.W
222223
"customCalculatedStatus": Phase(obj.(*v1.Pod)),
223224
}
224225
}
226+
if args.ResourceType == "nodes" {
227+
obj, _, err := scheme.Codecs.UniversalDeserializer().Decode(b, nil, nil)
228+
if err != nil {
229+
shared.LogError("Watcher routine: failed to unstructure resource: %v", err)
230+
return
231+
}
232+
rawJson["devops"] = map[string]interface{}{
233+
"customCalculatedStatus": nodeStatus(obj.(*v1.Node).Status.Conditions, obj.(*v1.Node).Spec.Unschedulable),
234+
}
235+
}
225236

226237
ch <- shared.WatchResourceResult{
227238
Type: strings.ToLower(string(event.Type)),

‎plugins/kubernetes/operations.go

+30
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,36 @@ func (d *Kubernetes) listResources(ctx context.Context, args *proto.GetResources
403403
return result, nil
404404
}
405405

406+
func nodeStatus(conds []v1.NodeCondition, exempt bool) string {
407+
res := make([]string, 0)
408+
conditions := make(map[v1.NodeConditionType]*v1.NodeCondition, len(conds))
409+
for n := range conds {
410+
cond := conds[n]
411+
conditions[cond.Type] = &cond
412+
}
413+
414+
validConditions := []v1.NodeConditionType{v1.NodeReady}
415+
for _, validCondition := range validConditions {
416+
condition, ok := conditions[validCondition]
417+
if !ok {
418+
continue
419+
}
420+
neg := ""
421+
if condition.Status != v1.ConditionTrue {
422+
neg = "Not"
423+
}
424+
res = append(res, neg+string(condition.Type))
425+
}
426+
if len(res) == 0 {
427+
res = append(res, "Unknown")
428+
}
429+
if exempt {
430+
res = append(res, "SchedulingDisabled")
431+
}
432+
433+
return strings.Join(res, ",")
434+
}
435+
406436
// Phase reports the given pod phase.
407437
func Phase(po *v1.Pod) string {
408438
status := string(po.Status.Phase)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
operations:
2+
- name: "namespace"
3+
json_paths:
4+
- path: "metadata.namespace"
5+
output_format: ""
6+
- name: "name"
7+
json_paths:
8+
- path: "metadata.name"
9+
output_format: ""
10+
- name: "status"
11+
json_paths:
12+
- path: "devops.customCalculatedStatus"
13+
output_format: ""
14+
- name: "version"
15+
json_paths:
16+
- path: "status.nodeInfo.kubeletVersion"
17+
output_format: ""
18+
- name: "pods"
19+
json_paths:
20+
- path: "status.capacity.na"
21+
- path: "status.capacity.pods"
22+
output_format: "%v/%v"
23+
- name: "age"
24+
json_paths:
25+
- path: "metadata.creationTimestamp|@age"
26+
output_format: ""
27+
styles:
28+
- row_background_color: darkorange
29+
conditions:
30+
- 'devops.customCalculatedStatus == "SchedulingDisabled" || devops.customCalculatedStatus == "Ready,SchedulingDisabled" || devops.customCalculatedStatus == "Not Ready,SchedulingDisabled"'
31+
- row_background_color: mediumpurple
32+
conditions:
33+
- 'devops.customCalculatedStatus == "Terminating"'
34+
- row_background_color: lightskyblue
35+
conditions:
36+
- 'devops.customCalculatedStatus == "Ready"'
37+
- row_background_color: red
38+
conditions:
39+
- "true"
40+
specific_actions:
41+
- name: "describe"
42+
key_binding: "d"
43+
execution:
44+
cmd: |
45+
#!/bin/bash
46+
kubectl describe {{.resourceType}} {{.resourceName}} -n "{{.isolatorName}}" --kubeconfig {{.authPath}} --context {{.authName}}
47+
output_type: "string"
48+
- name: "cordon"
49+
key_binding: "c"
50+
execution:
51+
cmd: |
52+
#!/bin/bash
53+
kubectl cordon {{.resourceName}} --kubeconfig {{.authPath}} --context {{.authName}}
54+
output_type: "nothing"
55+
- name: "uncordon"
56+
key_binding: "c"
57+
execution:
58+
cmd: |
59+
#!/bin/bash
60+
kubectl uncordon {{.resourceName}} --kubeconfig {{.authPath}} --context {{.authName}}
61+
output_type: "nothing"
62+
- name: "drain"
63+
key_binding: "c"
64+
execution:
65+
cmd: |
66+
#!/bin/bash
67+
kubectl drain {{.resourceName}} --delete-emptydir-data={{.args.deleteLocalData}} --force={{.args.force}} --grace-period={{.args.gracePeriod}} --ignore-daemonsets={{.args.ignoreDaemonSets}} --kubeconfig {{.authPath}} --context {{.authName}}
68+
user_input:
69+
required: true
70+
args:
71+
# The below template returns the first container port of the first container of the pod
72+
gracePeriod: "-1"
73+
ignoreDaemonSets: "false"
74+
deleteLocalData: "false"
75+
force: "false"
76+
server_input:
77+
required: false
78+
output_type: "string"

‎readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This project is inspired from the following softwares terraform, K9s, Lens.
1818
## Installation
1919
**Linux & Mac**
2020

21-
`curl https://storage.googleapis.com/devops-cli-artifacts/releases/devops/0.5.2/install.sh | bash`
21+
`curl https://storage.googleapis.com/devops-cli-artifacts/releases/devops/0.5.3/install.sh | bash`
2222

2323
## Usage
2424

0 commit comments

Comments
 (0)
Please sign in to comment.