Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.5.3 #17

Merged
merged 2 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/version-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
git checkout ${{ steps.current-branch.outputs.branch}}
git checkout -b "temp-branch"
TIMESTAMP=$(date +%s)
git tag -a "v0.5.2" -m "dummy tag"
git tag -a "v0.5.3" -m "dummy tag"
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV

echo "Running script..."
Expand Down
2 changes: 1 addition & 1 deletion cmd/devops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/spf13/viper"
)

const VERSION = "0.5.2"
const VERSION = "0.5.3"

// @title NEW Devops API
// @version v0.1.0
Expand Down
Binary file added devops-frontend/src/assets/helmicon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added devops-frontend/src/assets/helmicon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added devops-frontend/src/assets/kubernetes32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions devops-frontend/src/components/sideNav/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Menu, MenuProps } from "antd"
import Sider from "antd/es/layout/Sider"
import { useEffect, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import Icon, { HomeOutlined } from '@ant-design/icons';
import { NavBarItem, NavBarState } from "../../redux/reducers/PluginSelectorReducer";
import {
PieChartOutlined, AppstoreFilled, RightCircleFilled
Expand All @@ -16,23 +17,31 @@ export type SideNavProps = {
newNavItem?: NavBarItem
}


import kubernetesImage from '../../assets/kubernetes32.png';
import helmImage from '../../assets/helmicon-32.png';

const SideNav: React.FC<SideNavProps> = ({ selectedItem, newNavItem }) => {
const navigate = useNavigate();
const dispatch = useDispatch();
const { items } = useSelector((state: NavBarState) => state.navBar);
const [collapsed, setCollapsed] = useState(true);
const [navBarItems, setNavBarItems] = useState<MenuItem[]>([])


function getNavBarItem(
auhtId: string,
pluginName: string,
label: React.ReactNode,
key: React.Key,
children?: MenuItem[],
icon?: ReactNode,
): MenuItem {
return {
// <img src={pluginName === "kubernetes" ? kubernetesImage : helmImage} />
style: { "display": "flex", "align-items": "center" },
key,
icon: label === "Plugins" ? <AppstoreFilled /> : <RightCircleFilled />,
icon: label === "Plugins" ? <AppstoreFilled /> : <img src={pluginName === "kubernetes" ? kubernetesImage : helmImage} />,
children,
label: label === "Plugins" ? label : `${pluginName} :: ${auhtId} :: ${label}`,
onClick: () => {
Expand Down
13 changes: 12 additions & 1 deletion plugins/kubernetes/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func (d *Kubernetes) Connect(authInfo *proto.AuthInfo) error {
// List all supported resources
resources, err := clientset.Discovery().ServerPreferredResources()
if err != nil {
return fmt.Errorf("failed to discover kubernetes resource types: %w", err)
shared.LogDebug("failed to discover kubernetes resource types: %w", err)
// return fmt.Errorf("failed to discover kubernetes resource types: %w", err)
}

// Resource Type List
Expand Down Expand Up @@ -222,6 +223,16 @@ func (d *Kubernetes) WatchResources(args *proto.GetResourcesArgs) (chan shared.W
"customCalculatedStatus": Phase(obj.(*v1.Pod)),
}
}
if args.ResourceType == "nodes" {
obj, _, err := scheme.Codecs.UniversalDeserializer().Decode(b, nil, nil)
if err != nil {
shared.LogError("Watcher routine: failed to unstructure resource: %v", err)
return
}
rawJson["devops"] = map[string]interface{}{
"customCalculatedStatus": nodeStatus(obj.(*v1.Node).Status.Conditions, obj.(*v1.Node).Spec.Unschedulable),
}
}

ch <- shared.WatchResourceResult{
Type: strings.ToLower(string(event.Type)),
Expand Down
30 changes: 30 additions & 0 deletions plugins/kubernetes/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,36 @@ func (d *Kubernetes) listResources(ctx context.Context, args *proto.GetResources
return result, nil
}

func nodeStatus(conds []v1.NodeCondition, exempt bool) string {
res := make([]string, 0)
conditions := make(map[v1.NodeConditionType]*v1.NodeCondition, len(conds))
for n := range conds {
cond := conds[n]
conditions[cond.Type] = &cond
}

validConditions := []v1.NodeConditionType{v1.NodeReady}
for _, validCondition := range validConditions {
condition, ok := conditions[validCondition]
if !ok {
continue
}
neg := ""
if condition.Status != v1.ConditionTrue {
neg = "Not"
}
res = append(res, neg+string(condition.Type))
}
if len(res) == 0 {
res = append(res, "Unknown")
}
if exempt {
res = append(res, "SchedulingDisabled")
}

return strings.Join(res, ",")
}

// Phase reports the given pod phase.
func Phase(po *v1.Pod) string {
status := string(po.Status.Phase)
Expand Down
78 changes: 78 additions & 0 deletions plugins/kubernetes/resource_config/nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
operations:
- name: "namespace"
json_paths:
- path: "metadata.namespace"
output_format: ""
- name: "name"
json_paths:
- path: "metadata.name"
output_format: ""
- name: "status"
json_paths:
- path: "devops.customCalculatedStatus"
output_format: ""
- name: "version"
json_paths:
- path: "status.nodeInfo.kubeletVersion"
output_format: ""
- name: "pods"
json_paths:
- path: "status.capacity.na"
- path: "status.capacity.pods"
output_format: "%v/%v"
- name: "age"
json_paths:
- path: "metadata.creationTimestamp|@age"
output_format: ""
styles:
- row_background_color: darkorange
conditions:
- 'devops.customCalculatedStatus == "SchedulingDisabled" || devops.customCalculatedStatus == "Ready,SchedulingDisabled" || devops.customCalculatedStatus == "Not Ready,SchedulingDisabled"'
- row_background_color: mediumpurple
conditions:
- 'devops.customCalculatedStatus == "Terminating"'
- row_background_color: lightskyblue
conditions:
- 'devops.customCalculatedStatus == "Ready"'
- row_background_color: red
conditions:
- "true"
specific_actions:
- name: "describe"
key_binding: "d"
execution:
cmd: |
#!/bin/bash
kubectl describe {{.resourceType}} {{.resourceName}} -n "{{.isolatorName}}" --kubeconfig {{.authPath}} --context {{.authName}}
output_type: "string"
- name: "cordon"
key_binding: "c"
execution:
cmd: |
#!/bin/bash
kubectl cordon {{.resourceName}} --kubeconfig {{.authPath}} --context {{.authName}}
output_type: "nothing"
- name: "uncordon"
key_binding: "c"
execution:
cmd: |
#!/bin/bash
kubectl uncordon {{.resourceName}} --kubeconfig {{.authPath}} --context {{.authName}}
output_type: "nothing"
- name: "drain"
key_binding: "c"
execution:
cmd: |
#!/bin/bash
kubectl drain {{.resourceName}} --delete-emptydir-data={{.args.deleteLocalData}} --force={{.args.force}} --grace-period={{.args.gracePeriod}} --ignore-daemonsets={{.args.ignoreDaemonSets}} --kubeconfig {{.authPath}} --context {{.authName}}
user_input:
required: true
args:
# The below template returns the first container port of the first container of the pod
gracePeriod: "-1"
ignoreDaemonSets: "false"
deleteLocalData: "false"
force: "false"
server_input:
required: false
output_type: "string"
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This project is inspired from the following softwares terraform, K9s, Lens.
## Installation
**Linux & Mac**

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

## Usage

Expand Down
Loading